From 2eec891c3c738eba46df41520d477322d8e6ea6b Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 28 Mar 2009 18:09:33 +0100 Subject: fix for globalize to honor the use of :include => :globalize_translations. also see http://github.com/hukl/globalize2/commit/e0935a0a6c0c7305e575d3a9962229bd5f44cb1a --- .../globalize2/lib/globalize/model/active_record/adapter.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb b/vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb index d1c8db8..71faebd 100644 --- a/vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb +++ b/vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb @@ -63,9 +63,17 @@ module Globalize def fetch_attribute(locale, attr_name) fallbacks = I18n.fallbacks[locale].map{|tag| tag.to_s}.map(&:to_sym) - translations = @record.globalize_translations.by_locales(fallbacks) + + # If the translations were included with + # :include => globalize_translations + # there is no need to query them again. + unless @record.globalize_translations.loaded? + translations = @record.globalize_translations.by_locales(fallbacks) + else + translations = @record.globalize_translations + end result, requested_locale = nil, locale - + # Walk through the fallbacks, starting with the current locale itself, and moving # to the next best choice, until we find a match. # Check the @globalize_set_translations cache first to see if we've just changed the -- cgit v1.3