Skip to content

Instantly share code, notes, and snippets.

@jsierles
Created August 31, 2009 16:36
Show Gist options
  • Select an option

  • Save jsierles/178552 to your computer and use it in GitHub Desktop.

Select an option

Save jsierles/178552 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
acts_as_authentic do |c|
c.crypto_provider = Authlogic::CryptoProviders::BCrypt
end
belongs_to :role
has_one :artist
has_attached_file :photo,
:styles => {
:thumb=> "100x100>",
:small => "150x150>",
:medium => "300x300>"
}
attr_accessor :password_confirmation
validates_presence_of :password, :if => :password_required?
validates_confirmation_of :password, :if => :password_required?
has_many :lessons, :through => :saved_lessons
has_many :saved_lessons
def self.authenticate(username, password)
find :first, :conditions => {:email => username, :password => password}
end
private
def password_required?
new_record?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment