Created
November 16, 2010 22:10
-
-
Save slbug/702618 to your computer and use it in GitHub Desktop.
devise + postgres. case-insensitive login.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### User model ### | |
class User < ActiveRecord::Base | |
before_save :lower_email | |
def lower_email | |
self.email = email.downcase | |
end | |
end | |
### Custom sessions controller ### | |
class SessionsController < Devise::SessionsController | |
def create | |
params[:user][:email].downcase! | |
super | |
end | |
end | |
### Modify existing emails in database ### | |
UPDATE "users" SET "email" = LOWER("email"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. This was handy.