Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise several models spread across Engines

I have a rails app comprising several engines that are mounted in combinations at a time. There is one engine for B2B side of the app where we have a separate 'User' model(Like a company) for devise authentication. Similarly there is one for end customers which again has its own model for authentication(Like: Users for the company). Similarly, there is another engine for the site admin that is implemented using ActiveAdmin for root level administration.

We might mount one, two or three engines at the same time in several combinations. The problem is that, we have different parent application controllers for each of them and different routers for each of them too. Something like:

devise.rb -- engine1

config.router_name = :engine1
config.parent_controller = 'Engine1::ApplicationController'

devise.rb -- engine2

config.router_name = :engine2
config.parent_controller = 'Engine2::ApplicationController'

But, of course, I can't have multiple conflicting config files.

I need help on how I can implement something like this on devise.

like image 447
Nerve Avatar asked Sep 16 '13 12:09

Nerve


1 Answers

You could use cancan gem with devise to manage roles and use multiple models/scopes at a time. Alternatively you can also try mcms authentication. But I would suggest you to also check the canard gem which is highly documented and may help you fill up the blanks faster. Hope this helps.

like image 196
Anto Dominic Avatar answered Oct 28 '22 17:10

Anto Dominic