0
我有四个型号N + 1与轨道关系与活动记录?
- 集团
- 报告
- 评论
- 用户
组=>的has_many =>报告
报告=>的has_many =>评论
注释=> belongs_to的=>用户
当我想显示一组我这样做
<%= @group.name %>
<%= @group.reports.includes(:comments).each do |report| %>
<%= report.name %>
<% report.comments.each do |comment| %>
<%= comment.name %>
<%= comment.user.name %>
<% end %>
<% end %>
什么是解决在这种情况下,N + 1查询问题的最佳途径?