diff --git a/app/models/comment.rb b/app/models/comment.rb index 213eb3cda..e0f2beb2a 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -91,7 +91,11 @@ class Comment < ApplicationRecord alias touch_by_reaction save def self.tree_for(commentable, limit = 0) - commentable.comments.includes(:user).arrange(order: "score DESC").to_a[0..limit - 1].to_h + commentable.comments + .includes(user: %i[setting profile]) + .arrange(order: "score DESC") + .to_a[0..limit - 1] + .to_h end def search_id diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb index 5805bdc7d..848ef034c 100644 --- a/app/views/comments/index.html.erb +++ b/app/views/comments/index.html.erb @@ -124,7 +124,7 @@
<% if @root_comment.present? %> <% cache ["comment_root-view-root_#{user_signed_in?}", @root_comment] do %> - <%= tree_for(@root_comment, @root_comment.subtree.includes(:user).arrange[@root_comment], @commentable) %> + <%= tree_for(@root_comment, @root_comment.subtree.includes(user: %i[setting profile]).arrange[@root_comment], @commentable) %> <% end %> <% else %> <% Comment.tree_for(@commentable).each do |comment, sub_comments| %>