Reputation: 46264
I currently have the following restful url:
/questions/2011/05/
My route for questions is:
match 'questions/:year/:month/' => 'Questions#month'
How can I validate the above year and month parameters at the route level so that:
In django, I can do the above with the following line:
url(r'^questions/(?P<year>\d{4})/(?P<month>\d{2})/$', 'questions.views.month'),
I'm looking through the rails guide and googling around and I cannot find the corresponding functionality at the routing level. Is the above meant to be done at the controller level?
Upvotes: 5
Views: 2628
Reputation: 84150
You are looking for the constraints option to the match method options hash.
match 'questions/:year/:month/' => 'questions#month', :constraints => {:year => /\d{4}/, :month => /\d{2}/}
Upvotes: 4