【发布时间】:2014-06-09 12:46:08
【问题描述】:
我即将将我的 rails 3 应用程序迁移到 rails 4。
我的资源中有一些额外的路线会造成一些问题。 我在路由文件中收到有关此行的错误消息:
resources :teams do
...
get 'apply' => 'teams#apply_membership', as: :apply_membership
post 'apply' => 'teams#apply_membership_save', as: :apply_membership
...
这是生成的错误信息
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
在 rails3 中,可以使用相同的别名定义 get 和 post 路由并将它们路由到不同的控制器方法。
我也可以在 rails4 中执行此操作吗? 如果是,它在我的路由文件中应该是什么样子?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 routes