tap/app/models/user.rb
2014-12-06 17:51:41 +01:00

27 lines
629 B
Ruby

# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# last_name :string(255)
# balance :integer default(0)
# nickname :string(255)
# password_digest :string(255)
# created_at :datetime
# updated_at :datetime
#
class User < ActiveRecord::Base
has_many :orders, -> { includes :products }
validates :name, presence: true
validates :last_name, presence: true
validates :nickname, presence: true, uniqueness: true
def full_name
"#{name} #{last_name}"
end
has_secure_password
end