0

如何使第二条路线工作?

resources :users, only: [:edit, :update]
get ':id', :to => 'users#show', :as =>'user'

由于第二行,Rails 给出了错误:

Invalid route name, already in use: 'user' 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
4

1 回答 1

1

(扩展我的评论以供将来的观众参考。)

切换路由的顺序将改变优先级,将get路由优先级赋予 RESTful 路由。

从新的文档中config/routes.rb

  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".
于 2013-09-23T04:12:34.003 回答