Sha256: 9d38c50b2bfc306c381fb4bebb17eb8a6e9623af262131de628a68fde4c173a1
Contents?: true
Size: 647 Bytes
Versions: 16
Compression:
Stored size: 647 Bytes
Contents
module Spina class User < ApplicationRecord has_secure_password has_secure_token :password_reset_token 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
16 entries across 16 versions & 1 rubygems