有三个类,HotActivity, Activity 和 ActivityType
HotActivity 和 Activity 是一对一的关系,Activity belongs to ActivityType
现在我的 controller 里这样写
@hot_activities = HotActivity.includes(:activity)
chrome 就会提示
user: william
N+1 Query detected
Activity => [:activity_type]
Add to your finder: :include => [:activity_type]
N+1 Query method call stack
如果我这样加上后
@hot_activities = HotActivity.includes(:activity => :activity_type)
它又提示
user: william
Unused Eager Loading detected
HotActivity => [:activity]
Remove from your finder: :include => [:activity] activities:575
Uniform Notifier activities:587
user: william
Unused Eager Loading detected
Activity => [:activity_type]
Remove from your finder: :include => [:activity_type]
真是搞不懂了,肯定那里有根本性的错误,希望大神指出来,先谢谢了