Skip to content

Instantly share code, notes, and snippets.

@Andrew8xx8
Created October 11, 2016 15:40
Show Gist options
  • Save Andrew8xx8/0eca7d277551135eec64b34117c4a244 to your computer and use it in GitHub Desktop.
Save Andrew8xx8/0eca7d277551135eec64b34117c4a244 to your computer and use it in GitHub Desktop.
can [:memberships, :members], Organization do |organization|
@user.has_role?(:resource_administrator, organization)
all_childrens = @user.admined_organizations.map do |user_admined_organization|
user_admined_organization.actable.get_descendent_memberships.where(member_type: Organization.types)
end
all_childrens.flatten.map do |membership|
membership.member == organization.actable
end.reduce(&:|)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment