Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save antunderwood/144549 to your computer and use it in GitHub Desktop.
Save antunderwood/144549 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
include Roleify::RoleifyableModel
include Clearance::User
attr_accessible :username
validates_presence_of :username
validates_uniqueness_of :username
def self.authenticate(email, password)
user = find(:first, :conditions => ['username = ? OR email = ?', email.to_s.downcase, email.to_s.downcase])
user && user.authenticated?(password) ? user : nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment