Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Rolify has_role with multiple resources - has_any_role?


  • Please log in to reply
No replies to this topic

#1 burmjohn

burmjohn

    Passenger

  • Members
  • 5 posts

Posted 05 September 2013 - 01:00 AM

Works if you just specify one single record as the resource

if user.has_role? :company_admin, Company.first
...
end

How can you specify multiple resource id's? Example Company 1, Company 2, Company 3?

i.e.

if user.has_role? :company_admin, Company.all
...
end

I was actually trying to do this:

if user.has_role? :company_user, Company.with_role(:company_user, user)
can :manage, Derp
...
end

Then I found has_any_role?, however I can't find any solid examples on how I could pass Company.all or using my example above Company.with_role(:company_user, user) to it.

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users