Установка: has_many: через ассоциацию в ассоциации own_to Ruby on Rails

У меня есть три модели, каждая из которых имеет следующие ассоциации:

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

Как вы можете видеть в прокомментированном тексте, я упомянул то, что мне нужно.

9
задан James Chevalier 10 May 2014 в 19:53
поделиться