我有三個用戶 - 投資者,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
。