From 2ed325a3e90fc17c2d52a26bd1799b5f4e4bdf88 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 6 Sep 2012 14:00:45 +0200 Subject: [PATCH] we already have the module objects, do not constantize I have also chosen a variable name that matches the parameter in the definition of load_missing_constant. --- activesupport/lib/active_support/dependencies.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index ad34567fb6657..48be96f176637 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -169,8 +169,12 @@ def self.exclude_from(base) end def const_missing(const_name) - namespace = name.presence || "Object" - Dependencies.load_missing_constant(Inflector.constantize(namespace), const_name) + # The interpreter does not pass nesting information, and in the + # case of anonymous modules we cannot even make the trade-off of + # assuming their name reflects the nesting. Resort to Object as + # the only meaningful guess we can make. + from_mod = anonymous? ? ::Object : self + Dependencies.load_missing_constant(from_mod, const_name) end def unloadable(const_desc = self)