Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11781

Is there a way to find all Rolify roles scoped to a resource

$
0
0

If I've got a number of roles which can all be scoped to the same resource (can be :administrator or :staff of an individual Agency instance), is there a single method which will return all of those roles, if I have a user and an agency?

Specifically-

User.rb  rolifyAgency.rb  resourcify # roles of :agent and :administrator exist on this resource

I'm looking for a single-method equivalent of @user.has_roles_for? @agency which will return true if the user has a role which points at that agency. Currently, I'm using (@user.roles & @agency.roles).eql? [] to check if this is the case, but hopefully there's a cleaner way to show it.


Viewing all articles
Browse latest Browse all 11781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>