Skip to content

Commit

Permalink
add vendor/ back to load paths; catch errors in constant loading
Browse files Browse the repository at this point in the history
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
  • Loading branch information
al2o3cr authored and dhh committed Nov 18, 2008
1 parent 1211896 commit 45ba4ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
34 changes: 19 additions & 15 deletions activesupport/lib/active_support/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions railties/lib/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 45ba4ec

Please sign in to comment.