Question

I'm using ActiveAdmin with CanCan gem and I have the next situation:

  • Two roles: admin, other.
  • The admin's header with three links: link1 | link2 | link3
  • Link 3 represents a Video resource.
  • The admin user can see links 1, 2 and 3
  • The other user can see link 1 and 2 but NOT 3

So, to make link 3 disappear. I can have an abilities.rb file with:

can :manage, Video #for admin users

and nothing for other users. This will make link 3 disappear. But, in other sections of my app I want other users with ability to "read Videos". When I add this ability, the link appears into the header again.

The question is: How can I preserve my :

can :read, Video #for other users

and disappear link 3 at the same time?

Was it helpful?

Solution 2

ActiveAdmin.register Video do
  menu :if => proc { !current_user.other? }

  # ...
end

OTHER TIPS

You should be able to override the default menu visibility for those people who have CanCan access but shouldn't see the menu item:

ActiveAdmin.register Video do
  menu false if current_user.other?

  # ...
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top