forked from OpenNeo/impress
fix n+1 query for translations on items#index
This commit is contained in:
parent
26ac3782ec
commit
b2822d901b
2 changed files with 4 additions and 2 deletions
|
@ -23,7 +23,7 @@ class ItemsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
|
elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
|
||||||
@items = Item.find(params[:ids])
|
@items = Item.includes(:translations).find(params[:ids])
|
||||||
assign_closeted!
|
assign_closeted!
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json { render :json => @items }
|
format.json { render :json => @items }
|
||||||
|
|
|
@ -65,7 +65,9 @@ class Item
|
||||||
end
|
end
|
||||||
|
|
||||||
result = FlexSearch.item_search(final_flex_params)
|
result = FlexSearch.item_search(final_flex_params)
|
||||||
result.loaded_collection
|
result.scoped_loaded_collection(
|
||||||
|
:scopes => {'Item' => Item.includes(:translations)}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Load the text query labels from I18n, so that when we see, say,
|
# Load the text query labels from I18n, so that when we see, say,
|
||||||
|
|
Loading…
Reference in a new issue