Sha256: fd6635b1c7ae3dfcfe4bab78d8d6efd1712ca6f8d1d4f196935cac033ebfd92c

Contents?: true

Size: 590 Bytes

Versions: 9

Compression:

Stored size: 590 Bytes

Contents

class User < ActiveRecord::Base

  has_secure_password({ validations: false })

  before_save :create_remember_token

  validates :name, presence: true, length: { maximum: 15 }, uniqueness: { case_sensitive: false }
  validates :password, presence: true, length: { minimum: 5 }, confirmation: true, :unless => lambda { |v| v.validate_password? }
  validates :level, presence: true

  def validate_password?
    password.blank? && password_confirmation.blank? && !self.new_record?
  end

  private

  def create_remember_token
    self.remember_token = SecureRandom.urlsafe_base64
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
snapuser-0.2.6 app/models/user.rb
snapuser-0.2.5 app/models/user.rb
snapuser-0.2.4 app/models/user.rb
snapuser-0.2.3 app/models/user.rb
snapuser-0.2.2 app/models/user.rb
snapuser-0.2.1 app/models/user.rb
snapuser-0.2.0 app/models/user.rb
snapuser-0.1.1 app/models/user.rb
snapuser-0.1.0 app/models/user.rb