From fa4bc90fbbe252c8ff12cdd25ed63b9053f61b33 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 18 Mar 2014 14:56:00 -0400 Subject: [PATCH] Remove another N+1 query from categories page --- app/models/category_list.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/category_list.rb b/app/models/category_list.rb index ba63fec278c..f1e679cb62d 100644 --- a/app/models/category_list.rb +++ b/app/models/category_list.rb @@ -40,6 +40,7 @@ class CategoryList @topics_by_id = {} @all_topics = Topic.where(id: category_featured_topics.map(&:topic_id)) + @all_topics = @all_topics.includes(:last_poster) if include_latest_posts? @all_topics.each do |t| t.include_last_poster = true if include_latest_posts? # hint for serialization @topics_by_id[t.id] = t