Skip to content

Instantly share code, notes, and snippets.

@adahl
Created November 16, 2010 23:03
Show Gist options
  • Save adahl/702697 to your computer and use it in GitHub Desktop.
Save adahl/702697 to your computer and use it in GitHub Desktop.
### DEVISE 1.1.3 ###
class User < ActiveRecord::Base
before_save :downcase_email
def self.find_for_authentication(conditions)
conditions[:email].try(:downcase!)
super
end
def self.find_or_initialize_with_error_by(attribute, value, error=:invalid)
value.downcase! if attribute == :email
super
end
protected
def downcase_email
self.email.downcase!
end
end
### DEVISE LATEST ###
class User < ActiveRecord::Base
before_save :downcase_email
def self.find_for_authentication(conditions)
conditions[:email].try(:downcase!)
super
end
def self.find_or_initialize_with_errors(required_attributes, attributes, error=:invalid)
attributes[:email].try(:downcase!)
super
end
protected
def downcase_email
self.email.downcase!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment