From cca78f10312900ed8f57cd5287a063221702c5d6 Mon Sep 17 00:00:00 2001 From: cpradio Date: Mon, 17 Nov 2014 15:43:22 -0500 Subject: [PATCH] Remove n+1 query on Categories --- app/models/group.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/group.rb b/app/models/group.rb index 498733cc1e4..fb43e0e1859 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -38,7 +38,7 @@ class Group < ActiveRecord::Base def posts_for(guardian, before_post_id=nil) user_ids = group_users.map {|gu| gu.user_id} - result = Post.where(user_id: user_ids).includes(:user, :topic).references(:posts, :topics) + result = Post.where(user_id: user_ids).includes(:user, :topic, :topic => :category).references(:posts, :topics, :category) .where('topics.archetype <> ?', Archetype.private_message) .where(post_type: Post.types[:regular])