module Ecom module Core class CrewContract < ApplicationRecord belongs_to :crew validates :contract_no, :from, :to, :place_of_work, :probation_period, :contract_type, presence: true validates :contract_no, uniqueness: true validate :validate_date_range def validate_date_range return unless from && to errors.add(:to, 'cannot be before from date.') if from >= to end end end end