Permalink
Browse files

routing guide: wildcard segments are quite flexible, go beyond the si…

…mple use case
  • Loading branch information...
1 parent 54477c9 commit a1fdf402c02f4ae8ef0b49c2481298565620efa6 @fxn fxn committed Aug 15, 2010
Showing with 16 additions and 0 deletions.
  1. +16 −0 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:

0 comments on commit a1fdf40

Please sign in to comment.