diff options
author | Vipul A M <vipulnsward@gmail.com> | 2017-01-21 20:24:57 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-21 20:24:57 +0530 |
commit | 66101a069d12388a4e28b54712b94881b068b2fc (patch) | |
tree | f59bc6afc8ad8894512e4deae8aefbd98a513b0e /actionpack/lib/action_dispatch | |
parent | c8c565e0b150065d510e5e086bd9b218a92fbfa9 (diff) | |
download | rails-66101a069d12388a4e28b54712b94881b068b2fc.tar.gz rails-66101a069d12388a4e28b54712b94881b068b2fc.tar.bz2 rails-66101a069d12388a4e28b54712b94881b068b2fc.zip |
Add examples for behaviour about redirection with and without options. Fixes #27715 [ci skip] (#27730)
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/redirection.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb index 4e2318a45e..dabc045007 100644 --- a/actionpack/lib/action_dispatch/routing/redirection.rb +++ b/actionpack/lib/action_dispatch/routing/redirection.rb @@ -137,6 +137,9 @@ module ActionDispatch # # get "/stories" => redirect("/posts") # + # This will redirect the user, while ignoring certain parts of the request, including query string, etc. + # `/stories`, `/stories?foo=bar`, etc all redirect to `/posts`. + # # You can also use interpolation in the supplied redirect argument: # # get 'docs/:article', to: redirect('/wiki/%{article}') @@ -165,6 +168,11 @@ module ActionDispatch # # get 'stores/:name', to: redirect(subdomain: 'stores', path: '/%{name}') # get 'stores/:name(*all)', to: redirect(subdomain: 'stores', path: '/%{name}%{all}') + # get '/stories', to: redirect(path: '/posts') + # + # This will redirect the user, while changing only the specified parts of the request, + # for example the `path` option in the last example. + # `/stories`, `/stories?foo=bar`, redirect to `/posts` and `/posts?foo=bar` respectively. # # Finally, an object which responds to call can be supplied to redirect, allowing you to reuse # common redirect routes. The call method must accept two arguments, params and request, and return |