Guest User

Untitled

a guest
Apr 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. # Filter results based on access rules
  2. def filter(results)
  3. results.delete_if do |res|
  4. case res
  5. when Contact
  6. # If you're not a manager of this client, you can't see their contacts
  7. if res.contactable.is_a?(Client)
  8. !current_user.manager?(res.contactable)
  9. end
  10. when Campaign
  11. # If you're not a manager of this client, you can't see their campaigns
  12. if res.client.is_a?(Client)
  13. !current_user.manager?(res.client)
  14. end
  15. end
  16. end
  17. end
Add Comment
Please, Sign In to add comment