Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clarify what arguments are passed to redirect blocks - fixes #11056

  • Loading branch information...
commit e1e7888fbc1fd21d6cbcab72adb398cdee74579a 1 parent 37b4276
@pixeltrix pixeltrix authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 guides/source/routing.md
View
6 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.
Please sign in to comment.
Something went wrong with that request. Please try again.