fix n+1 query for translations on items#index

This commit is contained in:
Emi Matchu 2013-01-21 19:47:01 -06:00
parent 26ac3782ec
commit b2822d901b
2 changed files with 4 additions and 2 deletions

View file

@ -23,7 +23,7 @@ class ItemsController < ApplicationController
end
end
elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
@items = Item.find(params[:ids])
@items = Item.includes(:translations).find(params[:ids])
assign_closeted!
respond_to do |format|
format.json { render :json => @items }

View file

@ -65,7 +65,9 @@ class Item
end
result = FlexSearch.item_search(final_flex_params)
result.loaded_collection
result.scoped_loaded_collection(
:scopes => {'Item' => Item.includes(:translations)}
)
end
# Load the text query labels from I18n, so that when we see, say,