I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do
I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do
var React = require('react'); | |
var Dropzone = require('react-dropzone'); | |
var axios = require('axios'); | |
exports = module.exports = React.createClass({ | |
_onDrop: function (files) { | |
var file = files[0]; | |
axios.get(ENDPOINT_TO_GET_SIGNED_URL, { | |
filename: file.name, |
## | |
## TOKEN/API KEY AUTHENTICATION | |
## This was based on blogger-advanced | |
## Continuing from the class we built this in... | |
## if not already done, you'll need to make an ApiKey table in the DB 'rails g model ApiKey token:string' | |
## | |
# app/controllers/api/v1/articles_controller.rb | |
class Api::V1::ArticlesController < ApplicationController | |
#... |
# app/controllers/emails_controller.rb
# Could not get gem letter_opener_web to work as intended,
# This is a simple alternative that uses delivery_method :test
class EmailsController < ActionController::Base
layout nil
def index
@deliveries = ActionMailer::Base.deliveries.reverse
Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.
In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.
Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j
class SubdomainValidator < ActiveModel::EachValidator | |
# http://matthewhutchinson.net/2010/10/27/rails-3-subdomain-validation-activemodeleachvalidator | |
def validate_each(object, attribute, value) | |
return unless value.present? | |
reserved_names = %w(www ftp mail pop smtp admin ssl sftp) | |
reserved_names = options[:reserved] if options[:reserved] | |
if reserved_names.include?(value) | |
object.errors[attribute] << 'cannot be a reserved name' | |
end |
<%= form_for(@thing) do |f| %> | |
<% if @thing.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@thing.errors.count, "error") %> prohibited this thing from being saved:</h2> | |
<ul> | |
<% @thing.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> |
@media (min-width:320px) { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ } | |
@media (min-width:480px) { /* smartphones, Android phones, landscape iPhone */ } | |
@media (min-width:600px) { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ } | |
@media (min-width:801px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ } | |
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ } | |
@media (min-width:1281px) { /* hi-res laptops and desktops */ } |
On Tue, Mar 12, 2013 at 1:26 PM, Martin Fowler [email protected] wrote:
The term pops up in some different places, so it's hard to know what it means without some context. In PoEAA I use the pattern Service Layer to represent a domain-oriented layer of behaviors that provide an API for the domain layer. This may or may not sit on top of a Domain Model. In DDD Eric Evans uses the term Service Object to refer to objects that represent processes (as opposed to Entities and Values). DDD Service Objects are often useful to factor out behavior that would otherwise bloat Entities, it's also a useful step to patterns like Strategy and Command.
It sounds like the DDD sense is the sense I'm encountering most often. I really need to read that book.
The conceptual problem I run into in a lot of codebases is that rather than representing a process, the "service objects" represent "a thing that does the process". Which sounds like a nitpicky difference, but it seems to have a real impact on how people us