I have an application requiring three User types(User, Agent, Admin) with login and requiring different devise modules.
User AgentAdmin AdminUser
confirmable Yes Yes No
lockable Yes Yes No
timeoutable No Yes Yes
Omniauthable Yes No No
database_authenticatable Yes Yes Yes
recoverable Yes Yes No
rememberable Yes Yes No
trackable Yes Yes Yes
validatable Yes Yes Yes
Further these users may have additional columns based on their type. So, I want to create different tables based on their type.
Depending on my requirements, I decided to handle AgentAdmin
and AdminUser
with ActiveAdmin with different namespaces(admin for AdminUser
, agent for AgentAdmin
). I have configured authentication_method
, current_user_method
and logout_link_path
for both these namespaces as below.
config.load_paths = [File.join(Rails.root,'app','admin'), File.join(Rails.root,'app','agent')]
config.namespace :admin do |admin|
admin.authentication_method = :authenticate_admin_user!
admin.current_user_method = :current_admin_user
admin.logout_link_path = :destroy_admin_user_session_path
end
config.namespace :agent do |agent|
agent.authentication_method = :authenticate_agent_admin!
agent.current_user_method = :current_agent_admin
agent.logout_link_path = :destroy_agent_admin_session_path
end
I have the following code in my routes.rb
:
devise_for :agent_admins, ActiveAdmin::Devise.config
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
This generates login paths only for admin_users
.
If I set config.default_namespace = :agent
in active_admin.rb config file, the login path for agent_admin
is generated, but not admin_users
.
All other ActiveAdmin paths are generated normally for both the namespaces.
How can I solve, to generate both the login
paths handled by activedmin
?
devise_for :agent_admins, ActiveAdmin::Devise.config.merge({path: '/agent'})
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
This solved the issue.
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