diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-03-29 02:59:24 +0700 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2011-03-29 10:12:17 +0100 |
commit | 51551a0a5bd6f7e4116bc3759a4d7c15634643dc (patch) | |
tree | c5502f9dc06798f1e1321b69119c2b24b69c1095 /railties | |
parent | 3d1e7c2645af6c187d5ab6d2a02bd1e7b9ad7af3 (diff) | |
download | rails-51551a0a5bd6f7e4116bc3759a4d7c15634643dc.tar.gz rails-51551a0a5bd6f7e4116bc3759a4d7c15634643dc.tar.bz2 rails-51551a0a5bd6f7e4116bc3759a4d7c15634643dc.zip |
Update the wildcard route to be non-greedy by default, therefore be able to match the (.:format) segment [#6605 state:resolved]
After some discussion with Andrew White, it seems like this is a better approach for handling a wildcard route. However, user can still bring back the old behavior by supplying `:format => false` to the route.
Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/routing.textile | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index c447fd911a..58b75b9a1d 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -557,6 +557,18 @@ match '*a/foo/*b' => 'test#index' would match +zoo/woo/foo/bar/baz+ with +params[:a]+ equals +"zoo/woo"+, and +params[:b]+ equals +"bar/baz"+. +NOTE: Starting from Rails 3.1, wildcard route will always matching the optional format segment by default. For example if you have this route: + +<ruby> +map '*pages' => 'pages#show' +</ruby> + +NOTE: By requesting +"/foo/bar.json"+, your +params[:pages]+ will be equals to +"foo/bar"+ with the request format of JSON. If you want the old 3.0.x behavior back, you could supply +:format => false+ like this: + +<ruby> +map '*pages' => 'pages#show', :format => false +</ruby> + h4. Redirection You can redirect any path to another path using the +redirect+ helper in your router: |