【发布时间】:2013-10-11 22:27:04
【问题描述】:
在 Rails 3.2 我正在使用这些路由声明:
get 'contact' => 'contact#new', :as => 'contact'
post 'contact' => 'contact#create', :as => 'contact'
它们导致 (rake routes):
contact_en GET /en/contact(.:format) contact#new {:locale=>"en"}
contact_de GET /de/kontakt(.:format) contact#new {:locale=>"de"}
contact_en POST /en/contact(.:format) contact#create {:locale=>"en"}
contact_de POST /de/kontakt(.:format) contact#create {:locale=>"de"}
现在 Rails 4.0 抱怨此配置:
无效的路由名称,已在使用:'contact' 您可能已经定义 使用
:as选项的两条同名路线,或者您可能是 覆盖已由具有相同资源的资源定义的路由 命名。
显然这些路由名称相同,但由于请求类型不同,我希望它们像以前一样被接受。
如何让 Rails 4 像以前在 3.2 中一样生成路由?
【问题讨论】:
标签: ruby-on-rails ruby routes ruby-on-rails-4