{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/30556648","id":30556648,"diff_hunk":"@@ -0,0 +1,63 @@\n+<% if namespaced? -%>\n+require_dependency \"<%= namespaced_file_path %>/application_controller\"\n+\n+<% end -%>\n+<% module_namespacing do -%>\n+class <%= controller_class_name %>Controller < ApplicationController\n+  before_action :set_<%= singular_table_name %>, only: [:show, :update, :destroy]\n+\n+  # GET <%= route_url %>\n+  def index\n+    @<%= plural_table_name %> = <%= orm_class.all(class_name) %>\n+\n+    render json: <%= \"@#{plural_table_name}\" %>\n+  end\n+\n+  # GET <%= route_url %>/1\n+  def show\n+    render json: <%= \"@#{singular_table_name}\" %>\n+  end\n+\n+  # POST <%= route_url %>\n+  def create\n+    @<%= singular_table_name %> = <%= orm_class.build(class_name, \"#{singular_table_name}_params\") %>\n+\n+    if @<%= orm_instance.save %>\n+      render json: <%= \"@#{singular_table_name}\" %>, status: :created, location: <%= \"@#{singular_table_name}\" %>\n+    else\n+      render json: <%= \"@#{orm_instance.errors}\" %>, status: :unprocessable_entity\n+    end\n+  end\n+\n+  # PATCH/PUT <%= route_url %>/1\n+  def update\n+    if @<%= orm_instance.update(\"#{singular_table_name}_params\") %>\n+      render json: <%= \"@#{singular_table_name}\" %>\n+    else\n+      render json: <%= \"@#{orm_instance.errors}\" %>, status: :unprocessable_entity\n+    end\n+  end\n+\n+  # DELETE <%= route_url %>/1\n+  def destroy\n+    @<%= orm_instance.destroy %>\n+\n+    head :no_content","path":"railties/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb","position":45,"original_position":45,"commit_id":"3d1671a427318c6f35ddaf0021a9d151857a92ef","original_commit_id":"3d1671a427318c6f35ddaf0021a9d151857a92ef","user":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"body":"Some months ago.","created_at":"2015-05-18T23:20:23Z","updated_at":"2015-05-18T23:20:23Z","html_url":"https://github.com/rails/rails/pull/19832#discussion_r30556648","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/19832","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/30556648"},"html":{"href":"https://github.com/rails/rails/pull/19832#discussion_r30556648"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/19832"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/19832","id":33699430,"html_url":"https://github.com/rails/rails/pull/19832","diff_url":"https://github.com/rails/rails/pull/19832.diff","patch_url":"https://github.com/rails/rails/pull/19832.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/19832","number":19832,"state":"open","locked":false,"title":"Rails api","user":{"login":"dhh","id":2741,"avatar_url":"https://avatars.githubusercontent.com/u/2741?v=3","gravatar_id":"","url":"https://api.github.com/users/dhh","html_url":"https://github.com/dhh","followers_url":"https://api.github.com/users/dhh/followers","following_url":"https://api.github.com/users/dhh/following{/other_user}","gists_url":"https://api.github.com/users/dhh/gists{/gist_id}","starred_url":"https://api.github.com/users/dhh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhh/subscriptions","organizations_url":"https://api.github.com/users/dhh/orgs","repos_url":"https://api.github.com/users/dhh/repos","events_url":"https://api.github.com/users/dhh/events{/privacy}","received_events_url":"https://api.github.com/users/dhh/received_events","type":"User","site_admin":false},"body":"[Description extracted from http://wyeworks.com/blog/2015/4/20/rails-api-is-going-to-be-included-in-rails-5/]\r\n\r\nA decision was made to incorporate Rails API into Rails core 🎉 🎉 🎉.\r\n\r\n# What Is Rails API?\r\n\r\nThe original idea behind Rails API was to serve as a starting point for a version of Rails better suited for JS-heavy apps. As of today, Rails API provides: trimmed down controllers and middleware stack together with a matching set of generators, all specifically tailored for API type applications.\r\n\r\n# Next steps\r\n\r\nWe still need to discuss the “Rails way” for API applications, how API apps should be built and, what features we’d like included from our original list of ideas. In particular:\r\n\r\n* Do we want to avoid asset generation in Rails by having a back-end and a front-end apps?\r\n* Do we prefer to have a single application and keep asset generation in Rails instead?\r\n* Do we like Active Model Serializers better than Jbuilder?\r\n* If not, can we make Rails API play nicely with Jbuilder?","created_at":"2015-04-20T19:48:51Z","updated_at":"2015-05-18T23:20:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a4ac908422b4ea5d5e5e39aff1fc7caa26edaede","assignee":null,"milestone":{"url":"https://api.github.com/repos/rails/rails/milestones/34","html_url":"https://github.com/rails/rails/milestones/5.0.0","labels_url":"https://api.github.com/repos/rails/rails/milestones/34/labels","id":665192,"number":34,"title":"5.0.0","description":null,"creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":94,"closed_issues":100,"state":"open","created_at":"2014-05-21T00:58:22Z","updated_at":"2015-05-04T15:04:28Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/rails/rails/pulls/19832/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/19832/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/19832/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/3d1671a427318c6f35ddaf0021a9d151857a92ef","head":{"label":"spastorino:rails-api","ref":"rails-api","sha":"3d1671a427318c6f35ddaf0021a9d151857a92ef","user":{"login":"spastorino","id":52642,"avatar_url":"https://avatars.githubusercontent.com/u/52642?v=3","gravatar_id":"","url":"https://api.github.com/users/spastorino","html_url":"https://github.com/spastorino","followers_url":"https://api.github.com/users/spastorino/followers","following_url":"https://api.github.com/users/spastorino/following{/other_user}","gists_url":"https://api.github.com/users/spastorino/gists{/gist_id}","starred_url":"https://api.github.com/users/spastorino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spastorino/subscriptions","organizations_url":"https://api.github.com/users/spastorino/orgs","repos_url":"https://api.github.com/users/spastorino/repos","events_url":"https://api.github.com/users/spastorino/events{/privacy}","received_events_url":"https://api.github.com/users/spastorino/received_events","type":"User","site_admin":false},"repo":{"id":502903,"name":"rails","full_name":"spastorino/rails","owner":{"login":"spastorino","id":52642,"avatar_url":"https://avatars.githubusercontent.com/u/52642?v=3","gravatar_id":"","url":"https://api.github.com/users/spastorino","html_url":"https://github.com/spastorino","followers_url":"https://api.github.com/users/spastorino/followers","following_url":"https://api.github.com/users/spastorino/following{/other_user}","gists_url":"https://api.github.com/users/spastorino/gists{/gist_id}","starred_url":"https://api.github.com/users/spastorino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spastorino/subscriptions","organizations_url":"https://api.github.com/users/spastorino/orgs","repos_url":"https://api.github.com/users/spastorino/repos","events_url":"https://api.github.com/users/spastorino/events{/privacy}","received_events_url":"https://api.github.com/users/spastorino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spastorino/rails","description":"Ruby on Rails http:/www.rubyonrails.org","fork":true,"url":"https://api.github.com/repos/spastorino/rails","forks_url":"https://api.github.com/repos/spastorino/rails/forks","keys_url":"https://api.github.com/repos/spastorino/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spastorino/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spastorino/rails/teams","hooks_url":"https://api.github.com/repos/spastorino/rails/hooks","issue_events_url":"https://api.github.com/repos/spastorino/rails/issues/events{/number}","events_url":"https://api.github.com/repos/spastorino/rails/events","assignees_url":"https://api.github.com/repos/spastorino/rails/assignees{/user}","branches_url":"https://api.github.com/repos/spastorino/rails/branches{/branch}","tags_url":"https://api.github.com/repos/spastorino/rails/tags","blobs_url":"https://api.github.com/repos/spastorino/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spastorino/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spastorino/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/spastorino/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spastorino/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/spastorino/rails/languages","stargazers_url":"https://api.github.com/repos/spastorino/rails/stargazers","contributors_url":"https://api.github.com/repos/spastorino/rails/contributors","subscribers_url":"https://api.github.com/repos/spastorino/rails/subscribers","subscription_url":"https://api.github.com/repos/spastorino/rails/subscription","commits_url":"https://api.github.com/repos/spastorino/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/spastorino/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/spastorino/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/spastorino/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/spastorino/rails/contents/{+path}","compare_url":"https://api.github.com/repos/spastorino/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spastorino/rails/merges","archive_url":"https://api.github.com/repos/spastorino/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spastorino/rails/downloads","issues_url":"https://api.github.com/repos/spastorino/rails/issues{/number}","pulls_url":"https://api.github.com/repos/spastorino/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/spastorino/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/spastorino/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spastorino/rails/labels{/name}","releases_url":"https://api.github.com/repos/spastorino/rails/releases{/id}","created_at":"2010-02-04T21:09:54Z","updated_at":"2015-03-10T00:47:31Z","pushed_at":"2015-05-15T14:31:05Z","git_url":"git://github.com/spastorino/rails.git","ssh_url":"git@github.com:spastorino/rails.git","clone_url":"https://github.com/spastorino/rails.git","svn_url":"https://github.com/spastorino/rails","homepage":"http://contributors.rubyonrails.org/contributors/santiago-pastorino/commits","size":115909,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":5,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"22ae4493a3a09ab223f22893b1badff97bc405ee","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-05-18T21:28:21Z","pushed_at":"2015-05-18T23:10:43Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":435961,"stargazers_count":26142,"watchers_count":26142,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10372,"mirror_url":null,"open_issues_count":788,"forks":10372,"open_issues":788,"watchers":26142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/19832"},"html":{"href":"https://github.com/rails/rails/pull/19832"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/19832"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/19832/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/19832/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/19832/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/3d1671a427318c6f35ddaf0021a9d151857a92ef"}}}}