aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-12-16 12:04:24 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-12-16 12:04:24 -0700
commit79ac05f553977c5c520ddf6e59b7f5fc908e7363 (patch)
tree7ca33c6f2245c046942abf1c88ddd2be5b1ad5b4 /guides/source
parentf0f4f543c82db02d936df63215e2e95c3f871521 (diff)
parentdc4429ca3b21005d0016fca78967c2ebbe9677c9 (diff)
downloadrails-79ac05f553977c5c520ddf6e59b7f5fc908e7363.tar.gz
rails-79ac05f553977c5c520ddf6e59b7f5fc908e7363.tar.bz2
rails-79ac05f553977c5c520ddf6e59b7f5fc908e7363.zip
Merge pull request #22506 from derekprior/dp-redirect_to_back_or_default
Add `redirect_to_back_or_default`
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/action_controller_overview.md2
-rw-r--r--guides/source/layouts_and_rendering.md7
2 files changed, 6 insertions, 3 deletions
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 7e43ba375a..6c622a3643 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -1150,7 +1150,7 @@ class ApplicationController < ActionController::Base
def user_not_authorized
flash[:error] = "You don't have access to this section."
- redirect_to :back
+ redirect_back(fallback_location: root_path)
end
end
diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md
index 71cc030f6a..4bb364c0f8 100644
--- a/guides/source/layouts_and_rendering.md
+++ b/guides/source/layouts_and_rendering.md
@@ -622,10 +622,13 @@ Another way to handle returning responses to an HTTP request is with `redirect_t
redirect_to photos_url
```
-You can use `redirect_to` with any arguments that you could use with `link_to` or `url_for`. There's also a special redirect that sends the user back to the page they just came from:
+You can use `redirect_back` to return the user to the page they just came from.
+This location is pulled from the `HTTP_REFERER` header which is not guaranteed
+to be set by the browser, so you must provide the `fallback_location`
+to use in this case.
```ruby
-redirect_to :back
+redirect_back(fallback_location: root_path)
```
#### Getting a Different Redirect Status Code