Created
February 12, 2013 19:30
-
-
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
email = '[email protected]'.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