Active Admin Authorization by CanCan gem when User and ActiveAdmin have same model
I already had a User model with different roles handled by cancan gem. Now i have implemented active admin gem in the same User model with another role. Now i could not figure out how to restrict active admin views. I have tried different things like
can :read, ActiveAdmin::Page, name: "Dashboard", namespace_name: "admin"
in abilty.rb for the active admin role but this stuck in an infinite loop of requests to "/admin" and displays nothing. Thanks for help in advance.
Here are my active admin configurations
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