From 99e88ce39f8d62bbafae2a6a6ab919074e120224 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 29 Jun 2016 18:41:22 -0400 Subject: [PATCH] FIX: n+1 query when fetching tag groups --- app/controllers/tag_groups_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/tag_groups_controller.rb b/app/controllers/tag_groups_controller.rb index 36d955268fd..050aaa423ca 100644 --- a/app/controllers/tag_groups_controller.rb +++ b/app/controllers/tag_groups_controller.rb @@ -4,7 +4,7 @@ class TagGroupsController < ApplicationController before_filter :fetch_tag_group, only: [:show, :update, :destroy] def index - tag_groups = TagGroup.order('name ASC').preload(:tags).all + tag_groups = TagGroup.order('name ASC').includes(:parent_tag).all serializer = ActiveModel::ArraySerializer.new(tag_groups, each_serializer: TagGroupSerializer, root: 'tag_groups') respond_to do |format| format.html do