4
如何为此路由创建路径助手?Rails 3.1.3按日期定制路由
resources :news
match 'news/:year/:month/:day' => 'news#show',
:constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ },
:as => 'newsdate'
我尝试了很多方法,但它不工作:
link_to news.created_at.strftime '%d.%m.%Y ', newsdate_path(:year => '2011', :month => '11', :day => '11')
我得到的应用程序错误此行由GET http://localhost:3000/news:
ArgumentError in News#index
Showing /home/foxweb/work/dev/app/views/news/index.html.slim where line #6 raised:
wrong number of arguments (2 for 1)
如何作出正确的方法是什么?
P.S. http://localhost:3000/news/2011/11/11工作正常。
换句话说,错误发生在link_to内,而不是路由。 – 2011-12-21 23:53:27
好吧,我是...但是 路由错误 '没有路由匹配{:controller =>“news”,:action =>“show”,:year => 2004,:month => 9,:day => 15}' – foxwwweb 2011-12-22 04:32:25
向我们展示您的'rake routes'输出。 – 2011-12-22 11:23:15