Email validation should not be case-sensitive
When you try to add a new user with an email address that already exists in the database (e.g. [email protected]) but is spelled with a different case (e.g. [email protected]) it is not detected by the validations. Since email addresses are always not case-sensitive, devise should honor that.
See also here: http://groups.google.com/group/plataformatec-devise/browse_thread/thread/da5299872c2ea280?pli=1
Rails: 3.0.0.rc Devise: 1.1.rc2
It already works this way in latest Devise (1.1.0).
This problem still exisits on Devise 1.1.3
Have this in Devise 1.1.5. I'm using the mongoid adapter so maybe that's where the problem is.
Still existing in Devise 1.1.5. Using it without any adapters.
####I'm using the following fix from http://goo.gl/33TVf in my app/models/user.rb: before_validation :lowercase_email def lowercase_email self.email = self.email.downcase end def self.find_for_authentication(conditions) conditions[:email].downcase! if conditions[:email] super(conditions) end
Thanks for the find_for_authentication fix.
An alternative to using callbacks for the email is to just override the email setter.
def email=(email)
write_attribute(:email, email.try(:downcase))
end
I just copied it from the quoted Google Group thread. Thanks for your solution, I find it to be even more straightforward.
Why is this closed? This issue still exists in devise-1.4.2.
You can configure it using case_insensitive_keys in your
config/initializers/devise.rb. If it is not there, update your config file
with rails g devise:install.