Skip to content

Instantly share code, notes, and snippets.

@slbug
Created November 16, 2010 22:10
Show Gist options
  • Save slbug/702618 to your computer and use it in GitHub Desktop.
Save slbug/702618 to your computer and use it in GitHub Desktop.
devise + postgres. case-insensitive login.
### 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");
@crazyDiamond
Copy link

Thanks. This was handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment