{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/22506","labels_url":"https://api.github.com/repos/rails/rails/issues/22506/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/22506/comments","events_url":"https://api.github.com/repos/rails/rails/issues/22506/events","html_url":"https://github.com/rails/rails/pull/22506","id":120577344,"number":22506,"title":"Add `redirect_to_back_or_default`","user":{"login":"derekprior","id":152152,"avatar_url":"https://avatars.githubusercontent.com/u/152152?v=3","gravatar_id":"","url":"https://api.github.com/users/derekprior","html_url":"https://github.com/derekprior","followers_url":"https://api.github.com/users/derekprior/followers","following_url":"https://api.github.com/users/derekprior/following{/other_user}","gists_url":"https://api.github.com/users/derekprior/gists{/gist_id}","starred_url":"https://api.github.com/users/derekprior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekprior/subscriptions","organizations_url":"https://api.github.com/users/derekprior/orgs","repos_url":"https://api.github.com/users/derekprior/repos","events_url":"https://api.github.com/users/derekprior/events{/privacy}","received_events_url":"https://api.github.com/users/derekprior/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"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},"milestone":null,"comments":6,"created_at":"2015-12-05T18:15:52Z","updated_at":"2015-12-06T01:24:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/22506","html_url":"https://github.com/rails/rails/pull/22506","diff_url":"https://github.com/rails/rails/pull/22506.diff","patch_url":"https://github.com/rails/rails/pull/22506.patch"},"body":"`redirect_to :back` is a somewhat common pattern in Rails apps, but it\r\nis not completely safe. There are a number of circumstances where HTTP\r\nreferrer information is not available on the request. This happens often\r\nwith bot traffic and occasionally to user traffic depending on browser\r\nsecurity settings.\r\n\r\nWhen there is no referrer available on the request, `redirect_to :back`\r\nwill raise `ActionController::RedirectBackError`, usually resulting in\r\nan application error.\r\n\r\n`redirect_to_back_or_default` is a helper I have added to many rails\r\napplications to avoid this situation and now I'm proposing it be added\r\nto Rails proper and encouraged in place of `redirect_to :back`."},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/162261955","html_url":"https://github.com/rails/rails/pull/22506#issuecomment-162261955","issue_url":"https://api.github.com/repos/rails/rails/issues/22506","id":162261955,"user":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"created_at":"2015-12-06T01:24:54Z","updated_at":"2015-12-06T01:24:54Z","body":"I definitely agree that this should replace `redirect_to :back` with this. Our general philosophy has been to avoid constructs which could allow bad user input to make the server 500 trivially. `rescue_from` is definitely not sufficient. \r\n\r\nThat said, I'm not huge on the method name, it feels a bit long and unweildly to me. "}}