Skip to content

Instantly share code, notes, and snippets.

@martinx
Created March 10, 2013 14:58
Show Gist options
  • Save martinx/5128885 to your computer and use it in GitHub Desktop.
Save martinx/5128885 to your computer and use it in GitHub Desktop.
class AdminUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :login, :password, :password_confirmation, :remember_me
attr_accessor :login
protected
def self.find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup
login = conditions.delete(:login)
where(conditions).where(["lower(email) = :value", { :value => login.strip.downcase }]).first
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment