diff options
author | Xavier Noria <fxn@hashref.com> | 2010-07-22 00:16:26 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-07-22 00:16:26 +0200 |
commit | b2818b24725e5bc468af8ef870c21f4098b20822 (patch) | |
tree | a96b15d8934e71a5dc9b3dcb6b8fc048b4390a0f /railties | |
parent | 680f0459a3a4fe59b215d26c2de03f963c2c29ee (diff) | |
download | rails-b2818b24725e5bc468af8ef870c21f4098b20822.tar.gz rails-b2818b24725e5bc468af8ef870c21f4098b20822.tar.bz2 rails-b2818b24725e5bc468af8ef870c21f4098b20822.zip |
routing guide: a "photo" resource has by convention paths under "photos", in plural
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/routing.textile | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index 72a76e25bb..ae80ba77e4 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -441,13 +441,13 @@ h4. Segment Constraints You can use the +:constraints+ option to enforce a format for a dynamic segment: <ruby> -match 'photo/:id' => 'photos#show', :constraints => { :id => /[A-Z]\d{5}/ } +match 'photos/:id' => 'photos#show', :constraints => { :id => /[A-Z]\d{5}/ } </ruby> -This route would match URLs such as +/photo/A12345+. You can more succinctly express the same route this way: +This route would match URLs such as +/photos/A12345+. You can more succinctly express the same route this way: <ruby> -match 'photo/:id' => 'photos#show', :id => /[A-Z]\d{5}/ +match 'photos/:id' => 'photos#show', :id => /[A-Z]\d{5}/ </ruby> +:constraints+ takes regular expression. However note that regexp anchors can't be used within constraints. For example following route will not work: @@ -472,7 +472,7 @@ You can also constrain a route based on any method on the <a href="action_contro You specify a request-based constraint the same way that you specify a segment constraint: <ruby> -match "photo", :constraints => {:subdomain => "admin"} +match "photos", :constraints => {:subdomain => "admin"} </ruby> You can also specify constrains in a block form: @@ -511,10 +511,10 @@ h4. Route Globbing Route globbing is a way to specify that a particular parameter should be matched to all the remaining parts of a route. For example <ruby> -match 'photo/*other' => 'photos#unknown' +match 'photos/*other' => 'photos#unknown' </ruby> -This route would match +photo/12+ or +/photo/long/path/to/12+, setting +params[:other]+ to +"12"+ or +"long/path/to/12"+. +This route would match +photos/12+ or +/photos/long/path/to/12+, setting +params[:other]+ to +"12"+ or +"long/path/to/12"+. h4. Redirection |