【发布时间】:2011-05-07 14:45:17
【问题描述】:
我目前有以下restful url:
/questions/2011/05/
我的提问途径是:
match 'questions/:year/:month/' => 'Questions#month'
如何在路由级别验证上述年份和月份参数,以便:
- 年月为整数
- 一年的最小/最大长度 = 4
- 月的最小/最大长度 = 2
在 django 中,我可以使用以下行来完成上述操作:
url(r'^questions/(?P<year>\d{4})/(?P<month>\d{2})/$', 'questions.views.month'),
我正在浏览 Rails 指南并四处搜索,但在路由级别找不到相应的功能。以上是否意味着在控制器级别完成?
【问题讨论】: