Skip to content

Instantly share code, notes, and snippets.

@agraves
Created February 12, 2013 19:30
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 agraves/4772621 to your computer and use it in GitHub Desktop.
Save agraves/4772621 to your computer and use it in GitHub Desktop.
Trying to write platform-independent case-insensitive email search (without wildcards). Is this really the best way to do this?
email = 'you@yours.com'.gsub('%', '')
users = User.arel_table
User.find_by_sql(
users.
project(:id).
where(users[:email].matches email).
to_sql
).first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment