我有两个简单的模型,ProjectSetting 和 ProjectSettingQuestions。ProjectSettingQuestions 属于 ProjectSetting。我想在查询 ProjectSetting 时加载 ProjectSettingQuestions 数据。似乎不可能用这个查询做到这一点:
ProjectSetting.includes(:project_setting_questions).where(:project_id=>params[:project_id])
参数不是问题。此行获取 ProjectSetting 数据,但不获取问题。谢谢!
日志显示以下内容:
ProjectSetting Load (0.3ms) SELECT "project_settings".* FROM "project_settings" WHERE "project_settings"."project_id" = 31 LIMIT 1
ProjectSettingQuestion Load (0.4ms) SELECT "project_setting_questions".* FROM "project_setting_questions" WHERE "project_setting_questions"."project_setting_id" IN (2)