From 1863f12713ebbecb09361f72fa5343b8728aa7a1 Mon Sep 17 00:00:00 2001 From: thoefer Date: Sun, 12 Jun 2011 21:28:38 +0200 Subject: [PATCH] Make sure to have a Hash under the i18n keys 'activerecord.attributes' and 'activerecord.models' as this might not always be the case. See issue #1662. --- activerecord/lib/active_record/railtie.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 5502e3fc14..98ce58a837 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -99,18 +99,25 @@ module ActiveRecord config.after_initialize do container = :"activerecord.attributes" - I18n.t(container, :default => {}).each do |key, value| - if value.is_a?(Hash) && value.any? { |k,v| v.is_a?(Hash) } - $stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported" + lookup = I18n.t(container, :default => {}) + if lookup.is_a?(Hash) + lookup.each do |key, value| + if value.is_a?(Hash) && value.any? { |k,v| v.is_a?(Hash) } + $stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported" + end end end container = :"activerecord.models" - I18n.t(container, :default => {}).each do |key, value| - if value.is_a?(Hash) - $stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported" + lookup = I18n.t(container, :default => {}) + if lookup.is_a?(Hash) + lookup.each do |key, value| + if value.is_a?(Hash) + $stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported" + end end end end + end end