我期待創造的Rails 5以下型號: Industry
Department
JobTitle
示例數據: Industry: Technology, Healthcare, Other
Department: Admin, Customer Support
JobTitle: Account Manager, Accountant
行業是最高級別,部門可以屬於一個或更多的行業和職
比方說,我有以下ActiveRecord型號: class Car
belongs_to :driver
end
class Driver
# Has attribute :name
has_one :car
end
我定義了幾個使用這些模型工廠: FactoryGirl.define do
factory :car do
associ
我有以下模式: class Industry << ApplicationRecord
has_and_belongs_to_many :departments
end
# Relationship table: departments_industries
class Department << ApplicationRecord
has_and_belongs_t
我有以下Rail5 seeds.rb文件: 上面創建了s1-s4。 job_titles = JobTitle.all
job_titles.each_with_index do |job_title, index|
case job_title.title
when "XXXX"
self.create_job_title_skills([s1,s2,s3,s4]
我有以下型號: class Department < ApplicationRecord
has_many :department_job_titles
has_many :job_titles, through: :department_job_titles
end
class JobTitle < ApplicationRecord
has_and_belo