我遇到了以下有效记录查询的N + 1查询问题......
@interviews.each do |interview|
我想通过使用:college_play_histories
将.includes(:college_play_histories)
添加到活动记录查询来解决此问题,但目前在访谈和college_play_histories之间不存在该关联。我打算在Interview
和CollegePlayHistory
之间设置关联,但这对我来说似乎不正确,我不确定是否有办法在include中指定college_play_histories
{ {1}}。
要
player
以下是我目前的模特和协会:
访
@interviews.includes(:college_play_history).each do |interview|
播放器
class Interview < ActiveRecord::Base
belongs_to :player
end
CollegePlayHistory
class Player < ActiveRecord::Base
has_many :interviews
has_many :college_play_histories
end