Skip to content

Instantly share code, notes, and snippets.

@jmervine
Created April 14, 2017 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmervine/4aafef3274882c81a2941daacb468d7b to your computer and use it in GitHub Desktop.
Save jmervine/4aafef3274882c81a2941daacb468d7b to your computer and use it in GitHub Desktop.
cool, but never used
scope :find_by_eamil, ->(email) do
# Search team.
teams = joins(:team).where(teams: { email: email })
return teams unless teams.empty?
# Search user.
joins(:user).where(users: { email: email })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment