module Ecom module Core class Crew < ApplicationRecord PERMANENT = 'Permanent'.freeze TEMPORARY = 'Temporary'.freeze belongs_to :crew_type validates :name, :qualification, presence: true validates :employment, inclusion: [PERMANENT, TEMPORARY] #validates :wage, presence: true, if: ->(o) { o.employment == PERMANENT } #validates :wage, absence: true, if: ->(o) { o.employment == TEMPORARY } end end end