Skip to content

Email case sensitivity

croaky edited this page Sep 13, 2010 · 10 revisions

We made the decision that:

outweighed potential end user problems of case insensitivity.

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
end

Database index

For 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.

Clone this wiki locally