Sha256: bfb9b7a4f3003a630696b5570c074351fbe09a10e089aeb3920eb2d117a17726
Contents?: true
Size: 604 Bytes
Versions: 3
Compression:
Stored size: 604 Bytes
Contents
module Spina class User < ApplicationRecord has_secure_password validates_presence_of :name, :email validates_presence_of :password, on: :create validate :uniqueness_of_email validates :email, format: { with:/\A[^@]+@[^@]+\z/ } def admin? admin end def to_s name end def update_last_logged_in! self.last_logged_in = Time.now self.save! end private def uniqueness_of_email if email_changed? && User.where(email: email).exists? errors.add(:email, I18n.t('errors.messages.taken')) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spina-0.11.1 | app/models/spina/user.rb |
spina-0.11.0 | app/models/spina/user.rb |
spina-0.10.0 | app/models/spina/user.rb |