diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 5dbe466b7b3d2276dff73da1838e09d56377c844..67620e178966f01fd266ebc9e4c43b2ef533f0e6 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -485,24 +485,28 @@ def new_constants_in(*descs) # Build the watch frames. Each frame is a tuple of # [module_name_as_string, constants_defined_elsewhere] watch_frames = descs.collect do |desc| - if desc.is_a? Module - mod_name = desc.name - initial_constants = desc.local_constant_names - elsif desc.is_a?(String) || desc.is_a?(Symbol) - mod_name = desc.to_s - - # Handle the case where the module has yet to be defined. - initial_constants = if qualified_const_defined?(mod_name) - mod_name.constantize.local_constant_names + begin + if desc.is_a? Module + mod_name = desc.name + initial_constants = desc.local_constant_names + elsif desc.is_a?(String) || desc.is_a?(Symbol) + mod_name = desc.to_s + + # Handle the case where the module has yet to be defined. + initial_constants = if qualified_const_defined?(mod_name) + mod_name.constantize.local_constant_names + else + [] + end else - [] + raise Argument, "#{desc.inspect} does not describe a module!" end - else - raise Argument, "#{desc.inspect} does not describe a module!" + [mod_name, initial_constants] + rescue NameError + # mod_name isn't a valid constant name + nil end - - [mod_name, initial_constants] - end + end.compact constant_watch_stack.concat watch_frames diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 3e97a17e0ec9a103e7d63bfc430b8585324bc63a..16abe62d1b03e78c59e574e143c0d19c65f68ec4 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -901,6 +901,7 @@ def default_load_paths components config lib + vendor ).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) } paths.concat builtin_directories