Skip to content

Instantly share code, notes, and snippets.

@brunopgalvao
Last active October 3, 2018 16:24
Show Gist options
  • Save brunopgalvao/e2653316f09b150e74249b7fd8d267cd to your computer and use it in GitHub Desktop.
Save brunopgalvao/e2653316f09b150e74249b7fd8d267cd to your computer and use it in GitHub Desktop.
account dups
def check_for_existing_membership
accounts = Account.where(email_address: email)
accounts.each do |account|
if account.portals.pluck(:id) == portal.id
errors.add(:duplicate, 'The email is already associated with members of this organization')
return false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment