Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Filter results based on access rules
- def filter(results)
- results.delete_if do |res|
- case res
- when Contact
- # If you're not a manager of this client, you can't see their contacts
- if res.contactable.is_a?(Client)
- !current_user.manager?(res.contactable)
- end
- when Campaign
- # If you're not a manager of this client, you can't see their campaigns
- if res.client.is_a?(Client)
- !current_user.manager?(res.client)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment