FIX: n+1 query when fetching tag groups

This commit is contained in:
Neil Lalonde 2016-06-29 18:41:22 -04:00
parent 610d8a5cb1
commit 99e88ce39f
1 changed files with 1 additions and 1 deletions

View File

@ -4,7 +4,7 @@ class TagGroupsController < ApplicationController
before_filter :fetch_tag_group, only: [:show, :update, :destroy] before_filter :fetch_tag_group, only: [:show, :update, :destroy]
def index 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') serializer = ActiveModel::ArraySerializer.new(tag_groups, each_serializer: TagGroupSerializer, root: 'tag_groups')
respond_to do |format| respond_to do |format|
format.html do format.html do