Guest User

Untitled

a guest
Feb 11th, 2019
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. invitation_params = {
  2. team_id: 1,
  3. emails: ["beyonce@email.com","kelly@email.com","michelle@email.com"]
  4. }
  5.  
  6. def invite(invitation_params)
  7. team_id = invitation_params["team_id"]
  8. user_team_lookups = UserTeamLookup.where(team_id: team_id)
  9.  
  10. users_ids = user_tenant_lookups.pluck(:user_id)
  11. users = User.where(id: users_ids)
  12. emails = users.pluck(:email)
  13.  
  14. matches = emails & invitation_params["emails"]
  15. if matches.any?
  16. invitation_params["emails"] = invitation_params["emails"] - matches
  17. end
  18. end
Add Comment
Please, Sign In to add comment