move from with_translations to includes(:translations), since we dont usually care about requiring

This commit is contained in:
Emi Matchu 2013-01-21 19:52:16 -06:00
parent b2822d901b
commit dd30fbe0d7
5 changed files with 6 additions and 6 deletions

View file

@ -32,7 +32,7 @@ class ItemsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
unless localized_fragment_exist?('items#index newest_items') unless localized_fragment_exist?('items#index newest_items')
@newest_items = Item.newest.with_translations.limit(18) @newest_items = Item.newest.includes(:translations).limit(18)
end end
} }
format.js { render :json => {:error => '$q required'}} format.js { render :json => {:error => '$q required'}}
@ -102,7 +102,7 @@ class ItemsController < ApplicationController
raise ActiveRecord::RecordNotFound, 'Pet type not found' raise ActiveRecord::RecordNotFound, 'Pet type not found'
end end
@items = @pet_type.needed_items.with_translations. @items = @pet_type.needed_items.includes(:translations).
alphabetize_by_translations alphabetize_by_translations
assign_closeted! assign_closeted!

View file

@ -48,7 +48,7 @@ class OutfitsController < ApplicationController
unless localized_fragment_exist?('outfits#new newest_items') unless localized_fragment_exist?('outfits#new newest_items')
@newest_items = Item.newest.select([:id, :name, :thumbnail_url]). @newest_items = Item.newest.select([:id, :name, :thumbnail_url]).
with_translations.limit(9) includes(:translations).limit(9)
end end
unless localized_fragment_exist?('outfits#new latest_contribution') unless localized_fragment_exist?('outfits#new latest_contribution')

View file

@ -10,7 +10,7 @@ class PetsController < ApplicationController
redirect_to roulette_path redirect_to roulette_path
else else
raise Pet::PetNotFound unless params[:name] raise Pet::PetNotFound unless params[:name]
@pet = Pet.load(params[:name], :item_scope => Item.with_translations) @pet = Pet.load(params[:name], :item_scope => Item.includes(:translations))
if user_signed_in? if user_signed_in?
points = current_user.contribute! @pet points = current_user.contribute! @pet
else else

View file

@ -3,7 +3,7 @@ class SitemapController < ApplicationController
def index def index
respond_to do |format| respond_to do |format|
format.xml { @items = Item.with_translations.sitemap } format.xml { @items = Item.includes(:translations).sitemap }
end end
end end
end end

View file

@ -105,7 +105,7 @@ class Pet < ActiveRecord::Base
last_pet_loaded = nil last_pet_loaded = nil
reloaded_pets = Parallel.map(candidates.keys, :in_threads => 8) do |locale| reloaded_pets = Parallel.map(candidates.keys, :in_threads => 8) do |locale|
Rails.logger.info "Reloading #{name} in #{locale}" Rails.logger.info "Reloading #{name} in #{locale}"
reloaded_pet = Pet.load(name, :item_scope => Item.with_translations, reloaded_pet = Pet.load(name, :item_scope => Item.includes(:translations),
:locale => locale) :locale => locale)
Pet.connection_pool.with_connection { reloaded_pet.save! } Pet.connection_pool.with_connection { reloaded_pet.save! }
last_pet_loaded = reloaded_pet last_pet_loaded = reloaded_pet