Sha256: 5c8f4120e87be7e1e6c4c3f7fe4dae62510e282216ee4385b6a43967b123b75b
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require 'digest/sha1' class User < ActiveRecord::Base # == Extensions =========================================================== # == Constants ============================================================ # == Properties =========================================================== attr_accessible :name attr_accessible :password, :password_confirmation attr_accessor :password, :password_confirmation # == Relationships ======================================================== belongs_to :account # == Callbacks ============================================================ before_save :encrypt_password # == Validations ========================================================== validates :password, :confirmation => true # == Scopes =============================================================== # == Class Methods ======================================================== # == Instance Methods ===================================================== protected def encrypt_password # A proper implementation would use bcrypt, but this is just a # non-functional demonstration. self.password_crypt = Digest::SHA1.hexdigest( [ @password, SecureRandom.uuid ].join('$') ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
test_dummy-0.5.0 | test/models/user.rb |