2015-05-22 28 views
0

我有三個用戶 - 投資者,sme和管理員。 我有下面的代碼在我application_controller.rb爲什麼activeadmin將普通用戶與管理員用戶混淆?

class ApplicationController < ActionController::Base 
    protect_from_forgery with: :exception 
    devise_group :person, contains: [:investor,:sme] 

    before_action :authenticate_person! 

    before_action do |controller| 
    redirect_to root_path if devise_controller? && person_signed_in? 
    end 
end 

現在的問題是,當我登錄到管理面板我重定向回到投資者的登錄頁面。這裏是服務器日誌

Started GET "/admin" for 127.0.0.1 at 2015-05-22 22:40:14 +0530 
Processing by Admin::DashboardController#index as HTML 
Completed 401 Unauthorized in 4ms 


Started GET "/investors/sign_in" for 127.0.0.1 at 2015-05-22 22:40:14 +0530 
Processing by Investors::SessionsController#new as HTML 
Rendered investors/shared/_links.html.erb (4.0ms) 
Rendered investors/sessions/new.html.haml within layouts/application (48.0ms) 
Completed 200 OK in 2537ms (Views: 2532.5ms | ActiveRecord: 0.0ms) 

無論身份驗證是成功還是失敗,我都會重定向到投資者登錄頁面。
另外,當我作爲投資者或sme登錄時,我可以訪問管理頁面。 Activeadmin顯然讓我的普通用戶和管理員用戶感到困惑。下面是我的配置/初始化/ active_admin.rb文件

ActiveAdmin.setup do |config| 
    config.authentication_method = :authenticate_admin_user! 
    config.current_user_method = :current_admin_user 
    config.logout_link_path = :destroy_admin_user_session_path 
end 

我嘗試添加config.skip_before_action :authenticate_person!我active_admin.rb文件,以爲我application_controller的before_action :authenticate_person!可能會造成問題,但它拋出一個錯誤說undefined method devise_group for application controller

回答

2

我想通it..I不得不添加以下代碼在我的應用程序/管理/ dashboard.rb文件

controller do 
    skip_before_filter :authenticate_person! 
end 

曾試圖加入到config /初始化/ active_admin.rb config.skip_before_filter :authenticate_person!但它造成的錯誤undefined method devise_group for application controller。 儘管這樣做有效,但當我以普通用戶身份登錄時嘗試訪問/ admin /登錄頁面時,我得到了重定向循環。
希望這有助於卡住誰

相關問題