如何使用设计为不同的用户模型配置路由?
How to configure routes for different user models using devise?
我有两个不同的用户组,User 和 Flyer。
我已经为两个模型生成了视图和控制器,
rails g devise:controllers users/flyers
观看次数:
rails g devise:views users/flyers
这是我的 routes.rb:
Rails.application.routes.draw do
devise_for :flyers
devise_for :admins
resources :currencies
resources :broadcasts
devise_for :users, controllers: {
sessions: 'users/sessions',
registrations: 'flyers/registrations'
}
devise_for :flyers, controllers: {
sessions: 'flyers/sessions',
}
end
但是我在设计传单控制器路线时遇到错误:
Invalid route name, already in use: 'new_flyer_session' 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
我怎样才能有不同的路线?
谢谢
从顶部删除 devise_for :flyers
我有两个不同的用户组,User 和 Flyer。
我已经为两个模型生成了视图和控制器,
rails g devise:controllers users/flyers
观看次数:
rails g devise:views users/flyers
这是我的 routes.rb:
Rails.application.routes.draw do
devise_for :flyers
devise_for :admins
resources :currencies
resources :broadcasts
devise_for :users, controllers: {
sessions: 'users/sessions',
registrations: 'flyers/registrations'
}
devise_for :flyers, controllers: {
sessions: 'flyers/sessions',
}
end
但是我在设计传单控制器路线时遇到错误:
Invalid route name, already in use: 'new_flyer_session' 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
我怎样才能有不同的路线? 谢谢
从顶部删除 devise_for :flyers