2013-10-16 25 views
5

私は、ログインしていて異なる開発モジュールが必要な3つのユーザータイプ(ユーザー、エージェント、管理者)が必要なアプリケーションを持っています。ActiveAdminを使用した複数の管理タイプログインの処理

     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 

さらに、これらのユーザーは、そのタイプに基づいて追加の列を持つことがあります。したがって、私はそれらのタイプに基づいて異なるテーブルを作成したいと思います。

は私の要件に応じて、私は別の名前空間(AdminUserための管理者、AgentAdmin剤)とのActiveAdminAgentAdminAdminUserを処理することにしました。これらの両方のネームスペースに対して、authentication_method,current_user_methodlogout_link_pathを以下のように設定しました。

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 

私は私のroutes.rbに次のコードを持っている:

devise_for :agent_admins, ActiveAdmin::Devise.config 
devise_for :admin_users, ActiveAdmin::Devise.config 
ActiveAdmin.routes(self) 

これだけadmin_usersのログインパスを生成します。 active_admin.rb設定ファイルにconfig.default_namespace = :agentを設定すると、agent_adminのログインパスが生成されますが、admin_usersでは生成されません。

他のすべてのActiveAdminパスは、両方のネームスペースに対して正常に生成されます。

どのようにすれば、loginの両方のパスを生成し、activedminで処理することができますか?

答えて

10
devise_for :agent_admins, ActiveAdmin::Devise.config.merge({path: '/agent'}) 
devise_for :admin_users, ActiveAdmin::Devise.config 
ActiveAdmin.routes(self) 

これが問題を解決しました。

関連する問題