Skip to content

Instantly share code, notes, and snippets.

@amaia
Forked from radar/user_auth.rb
Created June 5, 2009 08:28
Show Gist options
  • Save amaia/124149 to your computer and use it in GitHub Desktop.
Save amaia/124149 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
require 'digest/md5'
validates_presence_of :email, :password
def self.authenticate(email, password)
User.find_by_email_and_password(email, Digest::MD5.hexdigest(password))
end
def password=(password)
self[:password] = Digest::MD5.hexdigest(password)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment