【发布时间】:2011-04-21 07:38:57
【问题描述】:
我有三个模型,每个模型都有以下关联:
class Model1 < ActiveRecord::Base
has_many :model2s
has_many :model3s
end
class Model2 < ActiveRecord::Base
belongs_to :model1
has_many :model3s, :through => :model1 # will this work? is there any way around this?
end
class Model3 < ActiveRecord::Base
belongs_to :model1
has_many :model2s, :through => :model1 # will this work? is there any way around this?
end
正如您在评论文本中看到的那样,我已经提到了我需要的内容。
【问题讨论】:
标签: ruby-on-rails ruby associations has-many-through belongs-to