{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/20276","labels_url":"https://api.github.com/repos/rails/rails/issues/20276/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/20276/comments","events_url":"https://api.github.com/repos/rails/rails/issues/20276/events","html_url":"https://github.com/rails/rails/pull/20276","id":79853674,"number":20276,"title":"Allow default_render to take a block to customize behavior when there's no template","user":{"login":"davetron5000","id":22282,"avatar_url":"https://avatars.githubusercontent.com/u/22282?v=3","gravatar_id":"","url":"https://api.github.com/users/davetron5000","html_url":"https://github.com/davetron5000","followers_url":"https://api.github.com/users/davetron5000/followers","following_url":"https://api.github.com/users/davetron5000/following{/other_user}","gists_url":"https://api.github.com/users/davetron5000/gists{/gist_id}","starred_url":"https://api.github.com/users/davetron5000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davetron5000/subscriptions","organizations_url":"https://api.github.com/users/davetron5000/orgs","repos_url":"https://api.github.com/users/davetron5000/repos","events_url":"https://api.github.com/users/davetron5000/events{/privacy}","received_events_url":"https://api.github.com/users/davetron5000/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/actionview","name":"actionview","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2015-05-23T13:51:35Z","updated_at":"2015-06-18T12:07:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/20276","html_url":"https://github.com/rails/rails/pull/20276","diff_url":"https://github.com/rails/rails/pull/20276.diff","patch_url":"https://github.com/rails/rails/pull/20276.patch"},"body":"In 0de4a23 the behavior when there is a missing template was changed to\r\nnot raise an error, but instead head :no_content.  This is a breaking\r\nchange and some gems rely on this happening.\r\n\r\nThis adds `raise_on_missing_template` to controllers that, when set to\r\n`true`, enables the old behavior\r\n\r\n<hr>\r\n\r\n# Previous description for some context\r\n\r\nDoing this to have a conversation, so not necessarily proposing this exact patch, but I need help.\r\n\r\n## Problem\r\n\r\nThe patch being reverted here changes `ActionController::Metal::ImplicitRender#default_render` in a way that isn't backwards compatible.  *Before* this patch, code like this:\r\n\r\n```ruby\r\n# note use of responders gem in here—could be an issue\r\ndef create\r\n  user = User.create(params)\r\n  if user.valid?\r\n    redirect_to users_path\r\n  else\r\n    respond_with user # intends to render the `new` template\r\n  end\r\nend\r\n```\r\n\r\nWould render the `new` template.  *After* the patch being reverted here, it does a `HEAD` with no content and error message that the `create` template cannot be found.\r\n\r\nSo, before, the code was not ever intending to render a `create` template, but the patch being reverted here checks.\r\n\r\n## Solution\r\n\r\nIt seems like the check for the template existing isn't right.  Seems like it should test if something valid would be rendered, and this:\r\n\r\n```ruby\r\nif template_exists?(action_name.to_s, _prefixes, variants: request.variant)\r\n```\r\n\r\ndoesn't check that.\r\n\r\n## Where I need help\r\n\r\nWhat I can't figure out is how `render(*args)` ends up rendering the `new` template, so I can't figure out how to make the `if` statement more consistent with the behavior of `render`.\r\n\r\nIt could certainly be an issue in the responders gem, but a glance at the definition of `respond_with` ( https://github.com/plataformatec/responders/blob/70bea715bb87c9e7bd402ef88406a72ca327bb12/lib/action_controller/respond_with.rb#L190 ) doesn't lead me to any insights.  In my case https://github.com/plataformatec/responders/blob/70bea715bb87c9e7bd402ef88406a72ca327bb12/lib/action_controller/respond_with.rb#L205 is calling `self.class.responder` which is the default.\r\n\r\nCan anyone point me to the right direction?"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/113131553","html_url":"https://github.com/rails/rails/pull/20276#issuecomment-113131553","issue_url":"https://api.github.com/repos/rails/rails/issues/20276","id":113131553,"user":{"login":"kaspth","id":350807,"avatar_url":"https://avatars.githubusercontent.com/u/350807?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspth","html_url":"https://github.com/kaspth","followers_url":"https://api.github.com/users/kaspth/followers","following_url":"https://api.github.com/users/kaspth/following{/other_user}","gists_url":"https://api.github.com/users/kaspth/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspth/subscriptions","organizations_url":"https://api.github.com/users/kaspth/orgs","repos_url":"https://api.github.com/users/kaspth/repos","events_url":"https://api.github.com/users/kaspth/events{/privacy}","received_events_url":"https://api.github.com/users/kaspth/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T12:07:52Z","updated_at":"2015-06-18T12:07:52Z","body":"@davetron5000 Congrats and well done!\r\n\r\nJust ping someone. I'll do it this time. @rafaelfranca @spastorino @matthewd I think this is ready to merge."}}