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查詢問題的最佳途徑?