【发布时间】:2016-02-24 11:33:52
【问题描述】:
所以,我的模型如下:
模型1 > 模型2 > 模型3 > 模型4 > 模型5
model1.rb
has_many :model2, dependent: true
has_many :model3, through: :model2
has_many :model4, ...?
has_many :model5, ...?
如何告诉 Rails Model1 有很多 Model4 和 Model5?
另外,对于model4,我这样做是不是太过分了:
add_foreign_key :model5, [:model1, :model2, :model3, :model4]
【问题讨论】:
标签: ruby-on-rails