Shaheryar Imtiaz

Joined

150 Experience
1 Lesson Completed
0 Questions Solved

Activity

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

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.