Skip to content

Instantly share code, notes, and snippets.

@adahl
Created January 20, 2011 10:16
Show Gist options
  • Save adahl/787698 to your computer and use it in GitHub Desktop.
Save adahl/787698 to your computer and use it in GitHub Desktop.
Case-insensitive email with devise
# 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