Sha256: 28ff3e9578c39a725db507a9961627afc9e2fed133873e5571d9ba85a62f5ece
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literals: true module Jobshop class Company < ApplicationRecord self.primary_keys = %i[ organization_id company_id ] # Because we have a column named +type+, Rails wants to activate STI # Disable it manually self.inheritance_column = nil after_initialize { self.company_id ||= SecureRandom.uuid if new_record? } belongs_to :organization, inverse_of: :companies has_many :company_people, inverse_of: :company, foreign_key: %i[ organization_id company_id ] belongs_to :created_by, class_name: "Jobshop::Person", foreign_key: %i[ organization_id created_by_id ] has_many :orders, inverse_of: :company, foreign_key: %i[ organization_id company_id ] has_many :people, through: :company_people, foreign_key: %i[ organization_id person_id ] has_many :rfqs, inverse_of: :company, foreign_key: %i[ organization_id company_id ] belongs_to :type, class_name: "Jobshop::Company::Type", foreign_key: %i[ organization_id type_id ], inverse_of: :companies 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/company.rb |