Permalink
Browse files

fixed regular expression in Specifying Constraints section

  • Loading branch information...
timsly committed Feb 26, 2012
1 parent 1e25d62 commit a3a73c4465f8860bf9c98809f41e8dd54466287c
Showing with 2 additions and 2 deletions.
  1. +2 −2 railties/guides/source/routing.textile
@@ -650,15 +650,15 @@ h4. Specifying Constraints
You can use the +:constraints+ option to specify a required format on the implicit +id+. For example:
<ruby>
-resources :photos, :constraints => {:id => /[A-Z][A-Z][0-9]+/}
+resources :photos, :constraints => {:id => /[a-z][A-Z][0-9]+/}
</ruby>
This declaration constrains the +:id+ parameter to match the supplied regular expression. So, in this case, the router would no longer match +/photos/1+ to this route. Instead, +/photos/RR27+ would match.
You can specify a single constraint to apply to a number of routes by using the block form:
<ruby>
-constraints(:id => /[A-Z][A-Z][0-9]+/) do
+constraints(:id => /[a-z][A-Z][0-9]+/) do
resources :photos
resources :accounts
end

0 comments on commit a3a73c4

Please sign in to comment.