module Ecom module Model class User < ApplicationRecord has_secure_password has_and_belongs_to_many :user_roles, join_table: 'ecom_model_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, length: { minimum: 6 } def full_name "#{first_name} #{last_name}" end end end end