mercredi 31 août 2016

How to configure routes for different user models using devise?

I have two different user groups, User and Flyer.

I have generated views and controllers for both the models using,

rails g devise:controllers users/flyers 

and for views:

rails g devise:views users/flyers

This is my 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

But I am getting error for devise for flyers controllers route:

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://ift.tt/1g4FQcF

How can I have different routes? Thanks

Aucun commentaire:

Enregistrer un commentaire