I have a resource, say Product , which can be accessed by two different user classes: say Customer and Admin . Inheritance between the two does not exist.
I use Devise for authentication:
I have these two controllers:
and
Now, depending on who is logging in ( Customer or Admin ), I want products_path point to the appropriate controller. And I want to avoid customers_products_path and admins_products_path , which is messy.
So, I set up my routes as such
# config/routes.rb devise_scope :admin do resources :products, module: 'admins' end devise_scope :customer do resources :products, module: 'customers' end
This does not work. When I log in as Customer , products_path still points to Admins::ProductsController#index , as it is defined first.
Any clue? What I want to do may just be impossible without hacking.
UPDATE According to the code , this is not feasible.
ruby-on-rails devise routes
Emmanuel turlay
source share