Sha256: 229b5b4dca7473ab0086f0fc78f053b3a19e3589aa22500fefbe3683ce53c29b
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
# frozen_string_literals: true module Jobshop class RFQ < ApplicationRecord self.primary_keys = %i[ organization_id rfq_id ] after_initialize { self.rfq_id ||= SecureRandom.uuid if new_record? } after_create { reload } belongs_to :organization, inverse_of: :rfqs belongs_to :customer, inverse_of: :rfqs, optional: true, foreign_key: %i[ organization_id customer_id ] belongs_to :requested_by, class_name: "Jobshop::Customer::Contact", primary_key: %i[ organization_id customer_id contact_id ], foreign_key: %i[ organization_id customer_id requested_by_id ], optional: true has_many :rfq_lines, inverse_of: :rfq, foreign_key: %i[ organization_id rfq_id ] def customer=(value) customer_id = (Jobshop::Customer === value) ? value.customer_id : value write_attribute(:customer_id, customer_id) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jobshop-0.0.167 | app/models/jobshop/rfq.rb |