Sha256: 905b3aa866b66ba392f2ee2437d19425ffc14c5923658d572ae0beb4df0af657
Contents?: true
Size: 803 Bytes
Versions: 17
Compression:
Stored size: 803 Bytes
Contents
module Ecom module Core class User < ApplicationRecord has_secure_password has_and_belongs_to_many :user_roles, join_table: 'ecom_core_users_user_roles' VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i.freeze validates :first_name, :last_name, :active, presence: true validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false } validates :password, presence: true, length: { minimum: 6 }, confirmation: true, if: :password scope :active, -> { where(active: true) } def full_name "#{first_name} #{last_name}" end def roles_for_module(code) user_roles.joins(:application_module).where('ecom_core_application_modules.code = ?', code) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems