查询double has_many:通过关联

时间:2015-11-23 09:03:18

标签: ruby-on-rails activerecord

我有一个双has_many:通过这样的关系:

class Survey < ActiveRecord::Base
  has_many :surveyquestions
  has_many :questions, through: :surveyquestions
end

class Question < ActiveRecord::Base
  has_many :surveyquestions
  has_many :surveys, through: :surveyquestions
  has_many :kpiquestions, dependent: :destroy
  has_many :kpis, through: :kpiquestions
end

class Kpi < ActiveRecord::Base
  has_many :kpiquestions
  has_many :questions, through: :kpiquestions
end

现在我想查询具有特定survey_id和特定kpi_id的问题,但我不确定如何查询?

0 个答案:

没有答案