我已经有一个由cancan gem处理的具有不同角色的用户模型。现在,我在具有另一个角色的同一用户模型中实现了主动管理。现在我不知道如何限制活动的管理员视图。我尝试了不同的事情,例如can :read, ActiveAdmin::Page, name: "Dashboard", namespace_name: "admin"
在abilty.rb中担任主动管理员角色,但这陷入了对“ / admin”的无限请求循环中却什么也没显示。预先感谢您的帮助这是我的活动管理员配置
ActiveAdmin.setup do |config|
config.root_to = 'users#index'
config.site_title = "Application"
config.authentication_method = :authenticate_user!
config.authorization_adapter = ActiveAdmin::CanCanAdapter
config.cancan_ability_class = "Ability"
config.current_user_method = :current_user
config.logout_link_path = :destroy_user_session_path
config.logout_link_method = :delete
end
您是否忘了像这样重定向到仪表板?
config.on_unauthorized_access = :access_denied
class ApplicationController < ActionController::Base
def access_denied(exception)
redirect_to admin_dashboard_path, alert: exception.message
end
end