0
会员人和公司通过就业和通过面试是不好的做法? 为什么,具体? 这个答案是否适用于一般的数据库,而不仅仅是rails?Rails - 使用多重has_many通过:关联加入相同的两个模型。冗余has_many通过:
实施例:
employment.rb
class Employment < ActiveRecord::Base
belongs_to :people
belongs_to :companies
end
interview.rb
class Interview < ActiveRecord::Base
belongs_to :people
belongs_to :companies
end
person.rb
class Person < ActiveRecord::Base
has_many :employments
has_many :interviews
has_many :companies, through: :employments
has_many :companies, through: :interviews
end
company.rb
class Company < ActiveRecord::Base
has_many :employments
has_many :interviews
has_many :companies, through: :employments
has_many :companies, through: :interviews
end
人和公司通过就业相关联,但也通过面试冗余。
你的“加盟”模式的一个意思,给了主力车型之一化名? – ahnbizcad
@ gwho5150我的意思是'主要'模型 - 重要的是当您引用相关模型的(集合)时避免歧义。 – MrTheWalrus