Sha256: ff98d96cb76a34050bbe864e5a6e0bee94981cd5854a7a0da8c23dd9f0bac39d
Contents?: true
Size: 906 Bytes
Versions: 13
Compression:
Stored size: 906 Bytes
Contents
module Ecom module Core class SiteCrew < ApplicationRecord TEMPORARY_SITE_CREW = 'Temporary site crew'.freeze PERMANENT_SITE_CREW = 'Permanent site crew'.freeze SITE_CREW_TYPES = [TEMPORARY_SITE_CREW, PERMANENT_SITE_CREW].freeze ACTIVE = 'Active'.freeze INACTIVE = 'Inactive'.freeze STATUSES = [ACTIVE, INACTIVE].freeze validates :crew_id, :crew, :site_id, :site, :start_date, :site_crew_type, :status, presence: true validates_uniqueness_of :site_id, scope: :crew_id, if: -> { status == 'Active' }, message: 'There can only be one record with status `Active` for a given site and crew' validates :site_crew_type, inclusion: SITE_CREW_TYPES validates :status, inclusion: STATUSES belongs_to :crew belongs_to :site end end end
Version data entries
13 entries across 13 versions & 1 rubygems