I am using Devise for my User model. I am also using ActiveAdmin which is using Devise as well for the AdminUser model.
I can sign in using an admin_user and a user independently of each other, but I have noticed if I sign out the User, the AdminUser is signed out as well. The same thing happens if I reverse it and sign out the AdminUser first.
What can I do to hopefully get around this?
routes.rb
devise_for :admin_users, ActiveAdmin::Devise.config
devise_for :users
get "dashboard/home"
ApplicationController
protected
def after_sign_in_path_for(resource)
if resource.is_a?(User)
stored_location_for(:user) || dashboard_home_path
elsif resource.is_a?(AdminUser)
stored_location_for(:admin_user) || admin_root_path(resource)
end
end
What you are looking for is a Devise configuration called sign_out_all_scopes
When a user signs out and it is set to true, all scopes are signed out for this user, both user and admin in your case.
In devise.rb search for sign_out_all_scopes and change its value to true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With