aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-08-16 01:10:34 +0200
committerXavier Noria <fxn@hashref.com>2010-08-16 01:14:09 +0200
commita1fdf402c02f4ae8ef0b49c2481298565620efa6 (patch)
treef8431543b1a1a59c982c8e18fdf8e71e989e98de /railties
parent54477c98482f37d547fa158155ae1624b1f7f7ac (diff)
downloadrails-a1fdf402c02f4ae8ef0b49c2481298565620efa6.tar.gz
rails-a1fdf402c02f4ae8ef0b49c2481298565620efa6.tar.bz2
rails-a1fdf402c02f4ae8ef0b49c2481298565620efa6.zip
routing guide: wildcard segments are quite flexible, go beyond the simple use case
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/routing.textile16
1 files changed, 16 insertions, 0 deletions
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index d92c66cfd2..457b6804b1 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -516,6 +516,22 @@ match 'photos/*other' => 'photos#unknown'
This route would match +photos/12+ or +/photos/long/path/to/12+, setting +params[:other]+ to +"12"+ or +"long/path/to/12"+.
+Wildcard segments do not need to be last in a route. For example
+
+<ruby>
+match 'books/*section/:title' => 'books#show'
+</ruby>
+
+would match +books/some/section/last-words-a-memoir+ with +params[:section]+ equals +"some/section"+, and +params[:title]+ equals +"last-words-a-memoir"+.
+
+Techincally a route can have even more than one wildard segment indeed, the matcher assigns segments to parameters in an intuitive way. For instance
+
+<ruby>
+match '*a/foo/*b' => 'test#index'
+</ruby>
+
+would match +zoo/woo/foo/bar/baz+ with +params[:a]+ equals +"zoo/woo"+, and +params[:b]+ equals +"bar/baz"+.
+
h4. Redirection
You can redirect any path to another path using the +redirect+ helper in your router: