Skip to content

Commit

Permalink
Improve AAU
Browse files Browse the repository at this point in the history
  • Loading branch information
Exelord committed Nov 5, 2016
1 parent e597450 commit f96096f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/monarchy/acts_as_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ def accessible_roles_for(resource, inheritnce)
def resource_and_inheritance_roles(resource)
hierarchy_ids = resource.hierarchy.ancestors.select(:id)
Monarchy.role_class.where(id:
Monarchy.role_class.joins(:members).where('monarchy_members.user_id': id)
.where('monarchy_roles.inherited': 't', 'monarchy_members.hierarchy_id': hierarchy_ids)
Monarchy.role_class.joins(:members).where(
'monarchy_members.user_id': id,
'monarchy_roles.inherited': 't',
'monarchy_members.hierarchy_id': hierarchy_ids
)
.select(:inherited_role_id))
.union(resource_roles(resource))
.distinct
Expand Down

0 comments on commit f96096f

Please sign in to comment.