Skip to content

Commit 00c12ff

Browse files
committed
Merge pull request rails#1675 from thoefer/3-1-stable
Fix for startup problems due to deprecation warning on nested models
2 parents fb1fd61 + 1863f12 commit 00c12ff

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

activerecord/lib/active_record/railtie.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,25 @@ class Railtie < Rails::Railtie
9999

100100
config.after_initialize do
101101
container = :"activerecord.attributes"
102-
I18n.t(container, :default => {}).each do |key, value|
103-
if value.is_a?(Hash) && value.any? { |k,v| v.is_a?(Hash) }
104-
$stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported"
102+
lookup = I18n.t(container, :default => {})
103+
if lookup.is_a?(Hash)
104+
lookup.each do |key, value|
105+
if value.is_a?(Hash) && value.any? { |k,v| v.is_a?(Hash) }
106+
$stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported"
107+
end
105108
end
106109
end
107110

108111
container = :"activerecord.models"
109-
I18n.t(container, :default => {}).each do |key, value|
110-
if value.is_a?(Hash)
111-
$stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported"
112+
lookup = I18n.t(container, :default => {})
113+
if lookup.is_a?(Hash)
114+
lookup.each do |key, value|
115+
if value.is_a?(Hash)
116+
$stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported"
117+
end
112118
end
113119
end
114120
end
121+
115122
end
116123
end

0 commit comments

Comments
 (0)