Skip to content

Instantly share code, notes, and snippets.

@radar
Created June 5, 2009 06:08
Show Gist options
  • Save radar/124101 to your computer and use it in GitHub Desktop.
Save radar/124101 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