module Ecom module Core class DimensionElement < ApplicationRecord LENGTH = 'Length'.freeze WIDTH = 'Width'.freeze HEIGHT = 'Height'.freeze RADIUS = 'Radius'.freeze DIAMETER = 'Diameter'.freeze DIMENSION_ELEMENT_NAMES = %w[LENGTH WIDTH HEIGHT RADIUS DIAMETER].freeze validates :work_product_id, :work_product, :measurement_unit_id, :measurement_unit, :amount, :dimension_element_name, presence: true validates :dimension_element_name, inclusion: DIMENSION_ELEMENT_NAMES validates :amount, numericality: { greater_than: 0 } belongs_to :work_product belongs_to :measurement_unit end end end