我有以下型号:ActiveRecord的查询多个连接
class Epic < ActiveRecord::Base
has_many :planograms
has_and_belongs_to_many :users
end
class Planogram < ActiveRecord::Base
belongs_to :epic
end
class User < ActiveRecord::Base
has_and_belongs_to_many :epics
end
还有一个epics_users
表。 我找不出如何编写ActiveRecord查询来获取特定用户的所有Planograms。我试过以下内容:
Planogram.joins(:epic).where(:epics_users => {:user_id => 1})
和许多其他组合,但我没有在ActiveRecord查询经验。