Sha256: 8eb91ca418155cc08455ee540b545026c3661065dfa6006fc67f78bf9932e09b
Contents?: true
Size: 919 Bytes
Versions: 1
Compression:
Stored size: 919 Bytes
Contents
module Comee module Core class CustomerOrderItem < ApplicationRecord before_save :calculate_total_price, unless: proc { |item| item.total_price } belongs_to :customer_order belongs_to :product belongs_to :unit validates :customer_item_no, :customer_item_description, :quantity, :price, :delivery_date, presence: true validates :quantity, :price, numericality: {greater_than_or_equal_to: 0} validates :total_price, numericality: {greater_than_or_equal_to: 0}, allow_nil: true def calculate_total_price self.total_price = price * quantity end def self.ransackable_attributes(_auth_object = nil) %w[id customer_order_id product_id unit_id customer_item_no customer_item_description delivery_date] end def self.ransackable_associations(_auth_object = nil) %w[customer_order product unit] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comee_core-0.2.12 | app/models/comee/core/customer_order_item.rb |