I have three devise models Student, Employer, Admin. I would like to not be able sign in simultaneously as Student, Admin and Employer.
How will be the best way to do that?
my routes
devise_for :admins, only: :sessions
devise_for :employers,
controllers: {
sessions: 'devise/employers_sessions'
}
authenticated :employer do
match 'dashboard' => 'employers#dashboard'
end
devise_for :students,
controllers: {
registrations: 'devise/students_registrations',
sessions: 'devise/students_sessions'
}
Map them to a single warden scope. The terminology sucks a bit, since a devise scope is apparently something different than a warden scope. Too bad they didn’t write the corresponding wiki entry. There is however a short line about that:
I suppose devise uses different scopes for each model. If you go dive into the source and see where they set the scope they use in the mapping between devise and warden, you should be able to change that to a single one for each of the three models. This would get you where you want to be.
Go try