Sha256: 601496aa813d395e9d0fcadad64ff533c61fab5e4c593e02217fd7c35fb14779

Contents?: true

Size: 659 Bytes

Versions: 5

Compression:

Stored size: 659 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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ecom_core-1.1.0 app/models/ecom/core/user.rb
ecom_core-1.0.25 app/models/ecom/core/user.rb
ecom_core-1.0.24 app/models/ecom/core/user.rb
ecom_core-1.0.23 app/models/ecom/core/user.rb
ecom_core-1.0.22 app/models/ecom/core/user.rb