Search code examples
ruby-on-rails-3activeadmincancan

How to hide the resource in activeadmin gem


I create an admin page by using activeadmin gem http://activeadmin.info/ I use cancan to authorize the privilege for 2 kind of user, user manage and book manage user.

My question is: How I hide the resource User when a book manage user log in to admin page? Active admin

I tried something like that but it didn't work

 menu false  if can? :manage, BookHeader 

or

 menu false  if authorize! :manage, BookHeader

Thanks for your help!


Solution

  • You have to use proc for build menu dynamicly

    Examples

    dynamic label

    menu :label => proc{current_admin_user.admin? ? "Accounts" : "My Account"}
    

    Display/Hide

     menu :if => proc{ can?(:manage, BookHeader ) }   
    

    For more info about integrating AA and CanCan read this article

    https://github.com/gregbell/active_admin/wiki/How-to-work-with-cancan