summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb12
1 files 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
63 63
64 def fetch_attribute(locale, attr_name) 64 def fetch_attribute(locale, attr_name)
65 fallbacks = I18n.fallbacks[locale].map{|tag| tag.to_s}.map(&:to_sym) 65 fallbacks = I18n.fallbacks[locale].map{|tag| tag.to_s}.map(&:to_sym)
66 translations = @record.globalize_translations.by_locales(fallbacks) 66
67 # If the translations were included with
68 # :include => globalize_translations
69 # there is no need to query them again.
70 unless @record.globalize_translations.loaded?
71 translations = @record.globalize_translations.by_locales(fallbacks)
72 else
73 translations = @record.globalize_translations
74 end
67 result, requested_locale = nil, locale 75 result, requested_locale = nil, locale
68 76
69 # Walk through the fallbacks, starting with the current locale itself, and moving 77 # Walk through the fallbacks, starting with the current locale itself, and moving
70 # to the next best choice, until we find a match. 78 # to the next best choice, until we find a match.
71 # Check the @globalize_set_translations cache first to see if we've just changed the 79 # Check the @globalize_set_translations cache first to see if we've just changed the