Created
January 20, 2011 10:16
-
-
Save adahl/787698 to your computer and use it in GitHub Desktop.
Case-insensitive email with devise
This file contains 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
# User model | |
before_save :downcase_email | |
class << self | |
def find_for_authentication(conditions) | |
conditions[:email].try(:downcase!) | |
super | |
end | |
def find_or_initialize_with_error_by(attribute, value, error=:invalid) | |
value.downcase! if attribute == :email | |
super | |
end | |
end | |
protected | |
def downcase_email | |
self.email.downcase! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment