0

I'm utilizing roles within AdminUsers inside Active Admin and am using CanCan to define access across different resources.

It's working well with regards to limiiting access, but I'm running into trouble hiding menus based on role.

According to the ActiveAdmin docs, the following should work:

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

In my ability.rb model file, I have

case user.role      
  when "admin"
can :manage, :all
cannot :manage, Company
  when "manager"
    can :manage, Program
can :manage, Client

I even added cannot :manage, AdminUser under manager as well in order to explicitly state it.

I'm trying to hide AdminUser menu when logged in as a "manager" role. Currently, it's still showing it to that user though if I click it, it correctly tells me that I'm not authorized.

RailsTweeter
  • 1,625
  • 3
  • 18
  • 33

1 Answers1

0

I figured this out.

I had two menu lines as follows: menu :if => proc{ can?(:manage, AdminUser) } menu :label => "Users"

The second line was messing up the first one, I modified to:

 menu :if => proc{ can?(:manage, AdminUser) }, :label => "Users"

and it worked correctly.

pjam
  • 6,356
  • 5
  • 30
  • 40
RailsTweeter
  • 1,625
  • 3
  • 18
  • 33