diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2013-06-25 06:58:33 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2013-06-25 07:01:01 +0100 |
commit | e1e7888fbc1fd21d6cbcab72adb398cdee74579a (patch) | |
tree | 34bc9da734cd0bf808379767f78a29f50add8972 /guides | |
parent | 37b4276dbf22382788f66bd5361f0736aadb0425 (diff) | |
download | rails-e1e7888fbc1fd21d6cbcab72adb398cdee74579a.tar.gz rails-e1e7888fbc1fd21d6cbcab72adb398cdee74579a.tar.bz2 rails-e1e7888fbc1fd21d6cbcab72adb398cdee74579a.zip |
Clarify what arguments are passed to redirect blocks - fixes #11056
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/routing.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/guides/source/routing.md b/guides/source/routing.md index 076b9dd176..592429952a 100644 --- a/guides/source/routing.md +++ b/guides/source/routing.md @@ -767,11 +767,11 @@ You can also reuse dynamic segments from the match in the path to redirect to: get '/stories/:name', to: redirect('/posts/%{name}') ``` -You can also provide a block to redirect, which receives the params and the request object: +You can also provide a block to redirect, which receives the symbolized path parameters and the request object: ```ruby -get '/stories/:name', to: redirect {|params, req| "/posts/#{params[:name].pluralize}" } -get '/stories', to: redirect {|p, req| "/posts/#{req.subdomain}" } +get '/stories/:name', to: redirect {|path_params, req| "/posts/#{path_params[:name].pluralize}" } +get '/stories', to: redirect {|path_params, req| "/posts/#{req.subdomain}" } ``` Please note that this redirection is a 301 "Moved Permanently" redirect. Keep in mind that some web browsers or proxy servers will cache this type of redirect, making the old page inaccessible. |