Sha256: a0720c193a6dcfe377f8cb4ded51c61f54fc299fe14f5618c595a994ac76f16f
Contents?: true
Size: 691 Bytes
Versions: 17
Compression:
Stored size: 691 Bytes
Contents
module Ecom module Core class MaterialIdentity < ApplicationRecord belongs_to :material_type belongs_to :material_sub_type, optional: true validates :material_type_id, :material_type, presence: true validate :material_category_hierarchy_validator def material_category_hierarchy_validator return if material_type_id.nil? || material_sub_type_id.nil? material_sub_type = MaterialSubType.find_by(id: material_sub_type_id) return unless material_sub_type.material_type_id != material_type_id errors.add(:material_type, 'The given material_sub_type does not belong to the given material_type') end end end end
Version data entries
17 entries across 17 versions & 1 rubygems