Sha256: 9460d7b2ee78db179d8234e784a6c3b6bb427de8e607ba49ee65bae786dd2f62

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literals: true

module Jobshop
  class Product < ApplicationRecord
    self.primary_keys = %i[ organization_id product_id ]

    after_initialize { self.product_id ||= SecureRandom.uuid if new_record? }

    belongs_to :organization, inverse_of: :products

    belongs_to :created_by, class_name: "Jobshop::Person",
      foreign_key: %i[ organization_id created_by_id ]

    has_one :routing_process, inverse_of: :product,
      foreign_key: %i[ organization_id product_id ]

    has_many :routing_steps, through: :routing_process

    validates :name, presence: true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.163 app/models/jobshop/product.rb