Ask A Question

Notifications

You’re not receiving notifications from this thread.

Active Admin Authorization by CanCan gem when User and ActiveAdmin have same model

Shaheryar Imtiaz asked in Rails

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
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.