Sha256: cb69859b372ec541a272015dbe4eda82ff8439afd212fd5c948775268e7c6411
Contents?: true
Size: 919 Bytes
Versions: 1
Compression:
Stored size: 919 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, conditions: -> { where(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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecom_core-1.2.35 | app/models/ecom/core/site_crew.rb |