mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
routing guide: a "photo" resource has by convention paths under "photos", in plural
This commit is contained in:
parent
198975ecee
commit
e9127ce7e8
1 changed files with 6 additions and 6 deletions
|
@ -441,13 +441,13 @@ h4. Segment Constraints
|
||||||
You can use the +:constraints+ option to enforce a format for a dynamic segment:
|
You can use the +:constraints+ option to enforce a format for a dynamic segment:
|
||||||
|
|
||||||
<ruby>
|
<ruby>
|
||||||
match 'photo/:id' => 'photos#show', :constraints => { :id => /[A-Z]\d{5}/ }
|
match 'photos/:id' => 'photos#show', :constraints => { :id => /[A-Z]\d{5}/ }
|
||||||
</ruby>
|
</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>
|
<ruby>
|
||||||
match 'photo/:id' => 'photos#show', :id => /[A-Z]\d{5}/
|
match 'photos/:id' => 'photos#show', :id => /[A-Z]\d{5}/
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
+:constraints+ takes regular expression. However note that regexp anchors can't be used within constraints. For example following route will not work:
|
+: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:
|
You specify a request-based constraint the same way that you specify a segment constraint:
|
||||||
|
|
||||||
<ruby>
|
<ruby>
|
||||||
match "photo", :constraints => {:subdomain => "admin"}
|
match "photos", :constraints => {:subdomain => "admin"}
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
You can also specify constrains in a block form:
|
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
|
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>
|
<ruby>
|
||||||
match 'photo/*other' => 'photos#unknown'
|
match 'photos/*other' => 'photos#unknown'
|
||||||
</ruby>
|
</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
|
h4. Redirection
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue