-
-
Notifications
You must be signed in to change notification settings - Fork 465
Email case sensitivity
croaky edited this page Sep 13, 2010
·
10 revisions
We made the decision that:
- meeting the RFC 5321 specification for email and
- keeping the database index intact
outweighed potential end user problems.
If you prefer the other side of the tradeoff, you can add a downcase_email callback in your User model:
before_save :downcase_email
protected
def downcase_email
self.email = email.to_s.downcase
endFor a few early versions of Clearance, we used the LOWER() SQL function on email for the authenticate method. That was to handle old records that may have uppercase characters. However, this caused the database not to use the database index. In an app with even just a few thousand users, that can make the authenticate method noticeably slower.
If you decide to use the downcase_email callback in your app, we recommend that you run a rake task that downcases the value of the email column for all the records in the users table.