{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/205324797","pull_request_review_id":140571766,"id":205324797,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTMyNDc5Nw==","diff_hunk":"@@ -10,6 +10,15 @@ module AbstractController\n   class ActionNotFound < StandardError\n   end\n \n+  # Raised when a nested respond_to is triggered.\n+  class DoubleRespondToError < StandardError","path":"actionpack/lib/abstract_controller/base.rb","position":5,"original_position":5,"commit_id":"8c31d1c7e1445049c2127d990dc9e20398db0e22","original_commit_id":"8c31d1c7e1445049c2127d990dc9e20398db0e22","user":{"login":"gmcgibbon","id":5162312,"node_id":"MDQ6VXNlcjUxNjIzMTI=","avatar_url":"https://avatars0.githubusercontent.com/u/5162312?v=4","gravatar_id":"","url":"https://api.github.com/users/gmcgibbon","html_url":"https://github.com/gmcgibbon","followers_url":"https://api.github.com/users/gmcgibbon/followers","following_url":"https://api.github.com/users/gmcgibbon/following{/other_user}","gists_url":"https://api.github.com/users/gmcgibbon/gists{/gist_id}","starred_url":"https://api.github.com/users/gmcgibbon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmcgibbon/subscriptions","organizations_url":"https://api.github.com/users/gmcgibbon/orgs","repos_url":"https://api.github.com/users/gmcgibbon/repos","events_url":"https://api.github.com/users/gmcgibbon/events{/privacy}","received_events_url":"https://api.github.com/users/gmcgibbon/received_events","type":"User","site_admin":false},"body":"Should we raise on any nested double `respond_to` call? I'm not familiar with a good reason to do this. We could also rename this to `RespondToMismatchError ` if we are ok with allowing nested `respond_to`s with matching types.","created_at":"2018-07-26T03:53:03Z","updated_at":"2018-07-26T04:04:15Z","html_url":"https://github.com/rails/rails/pull/27376#discussion_r205324797","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/27376","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/205324797"},"html":{"href":"https://github.com/rails/rails/pull/27376#discussion_r205324797"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/27376"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/27376","id":98232191,"node_id":"MDExOlB1bGxSZXF1ZXN0OTgyMzIxOTE=","html_url":"https://github.com/rails/rails/pull/27376","diff_url":"https://github.com/rails/rails/pull/27376.diff","patch_url":"https://github.com/rails/rails/pull/27376.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/27376","number":27376,"state":"open","locked":false,"title":"Raises exception when nesting respond_to calls","user":{"login":"ptoomey3","id":103360,"node_id":"MDQ6VXNlcjEwMzM2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/103360?v=4","gravatar_id":"","url":"https://api.github.com/users/ptoomey3","html_url":"https://github.com/ptoomey3","followers_url":"https://api.github.com/users/ptoomey3/followers","following_url":"https://api.github.com/users/ptoomey3/following{/other_user}","gists_url":"https://api.github.com/users/ptoomey3/gists{/gist_id}","starred_url":"https://api.github.com/users/ptoomey3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptoomey3/subscriptions","organizations_url":"https://api.github.com/users/ptoomey3/orgs","repos_url":"https://api.github.com/users/ptoomey3/repos","events_url":"https://api.github.com/users/ptoomey3/events{/privacy}","received_events_url":"https://api.github.com/users/ptoomey3/received_events","type":"User","site_admin":true},"body":"Nesting `respond_to` calls can lead to unexpected behavior, so it should be\r\navoided. Currently, the first `respond_to` format match sets the content-type\r\nfor the resulting response. But, if a nested `respond_to` call occurs, it is possible\r\nto match on a different format. For example:\r\n\r\n``` ruby\r\n    respond_to do |outer_type|\r\n      outer_type.js do\r\n        respond_to do |inner_type|\r\n          inner_type.html { render body: \"HTML\" }\r\n        end\r\n      end\r\n    end\r\n```\r\n\r\nBrowsers will often include `*/*` in their `Accept` headers. In the above example,\r\nsuch a request would result in the `outer_type.js` match setting the `content-type` of the response to `text/javascript`, while the `inner_type.html` match will\r\ncause the actual response to return an \"HTML\" response body.\r\n\r\nThis change tries to minimize potential breakage by only raising an exception\r\nif the nested respond_to calls are in conflict with each other. So, something\r\nlike the following example would not raise an exception:\r\n\r\n``` ruby\r\n    respond_to do |outer_type|\r\n      outer_type.js do\r\n        respond_to do |inner_type|\r\n          inner_type.js { render body: \"JS\" }\r\n        end\r\n      end\r\n    end\r\n```\r\n\r\nWhile the above is nested, it doesn't affect the content-type of the response. If people think it simpler/more obvious to just raise anytime a double `respond_to` occurs (ala a double render) that seems fine too. I'm conjecturing this could be a breaking change for some people, which is why I wanted to minimize breakage by only raising when we are in actual conflict. \r\n\r\n/cc @tenderlove - Since we had chatted about \"expected behavior\" of nested `respond_to` calls and the general feeling was \"raise YugeError\" :smile:. ","created_at":"2016-12-15T21:13:59Z","updated_at":"2018-07-26T04:04:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d434ec4a822f38fbfcff5763cda4ed8cb9ac682","assignee":{"login":"pixeltrix","id":6321,"node_id":"MDQ6VXNlcjYzMjE=","avatar_url":"https://avatars0.githubusercontent.com/u/6321?v=4","gravatar_id":"","url":"https://api.github.com/users/pixeltrix","html_url":"https://github.com/pixeltrix","followers_url":"https://api.github.com/users/pixeltrix/followers","following_url":"https://api.github.com/users/pixeltrix/following{/other_user}","gists_url":"https://api.github.com/users/pixeltrix/gists{/gist_id}","starred_url":"https://api.github.com/users/pixeltrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixeltrix/subscriptions","organizations_url":"https://api.github.com/users/pixeltrix/orgs","repos_url":"https://api.github.com/users/pixeltrix/repos","events_url":"https://api.github.com/users/pixeltrix/events{/privacy}","received_events_url":"https://api.github.com/users/pixeltrix/received_events","type":"User","site_admin":false},"assignees":[{"login":"pixeltrix","id":6321,"node_id":"MDQ6VXNlcjYzMjE=","avatar_url":"https://avatars0.githubusercontent.com/u/6321?v=4","gravatar_id":"","url":"https://api.github.com/users/pixeltrix","html_url":"https://github.com/pixeltrix","followers_url":"https://api.github.com/users/pixeltrix/followers","following_url":"https://api.github.com/users/pixeltrix/following{/other_user}","gists_url":"https://api.github.com/users/pixeltrix/gists{/gist_id}","starred_url":"https://api.github.com/users/pixeltrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixeltrix/subscriptions","organizations_url":"https://api.github.com/users/pixeltrix/orgs","repos_url":"https://api.github.com/users/pixeltrix/repos","events_url":"https://api.github.com/users/pixeltrix/events{/privacy}","received_events_url":"https://api.github.com/users/pixeltrix/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":107189,"node_id":"MDU6TGFiZWwxMDcxODk=","url":"https://api.github.com/repos/rails/rails/labels/actionpack","name":"actionpack","color":"FFF700","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/27376/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/27376/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/27376/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/8c31d1c7e1445049c2127d990dc9e20398db0e22","head":{"label":"ptoomey3:raise-on-nested-respond-to","ref":"raise-on-nested-respond-to","sha":"8c31d1c7e1445049c2127d990dc9e20398db0e22","user":{"login":"ptoomey3","id":103360,"node_id":"MDQ6VXNlcjEwMzM2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/103360?v=4","gravatar_id":"","url":"https://api.github.com/users/ptoomey3","html_url":"https://github.com/ptoomey3","followers_url":"https://api.github.com/users/ptoomey3/followers","following_url":"https://api.github.com/users/ptoomey3/following{/other_user}","gists_url":"https://api.github.com/users/ptoomey3/gists{/gist_id}","starred_url":"https://api.github.com/users/ptoomey3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptoomey3/subscriptions","organizations_url":"https://api.github.com/users/ptoomey3/orgs","repos_url":"https://api.github.com/users/ptoomey3/repos","events_url":"https://api.github.com/users/ptoomey3/events{/privacy}","received_events_url":"https://api.github.com/users/ptoomey3/received_events","type":"User","site_admin":true},"repo":null},"base":{"label":"rails:master","ref":"master","sha":"4b576f482152411097ecda0c4527bfb01a1d2965","user":{"login":"rails","id":4223,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMjM=","avatar_url":"https://avatars1.githubusercontent.com/u/4223?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnk4NTE0","name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMjM=","avatar_url":"https://avatars1.githubusercontent.com/u/4223?v=4","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}","deployments_url":"https://api.github.com/repos/rails/rails/deployments","created_at":"2008-04-11T02:19:47Z","updated_at":"2018-07-26T01:20:57Z","pushed_at":"2018-07-26T04:03:14Z","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":164670,"stargazers_count":40295,"watchers_count":40295,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16261,"mirror_url":null,"archived":false,"open_issues_count":1118,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":16261,"open_issues":1118,"watchers":40295,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/27376"},"html":{"href":"https://github.com/rails/rails/pull/27376"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/27376"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/27376/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/27376/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/27376/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/8c31d1c7e1445049c2127d990dc9e20398db0e22"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"gmcgibbon"}}