From 991cd59a225b90ab1ba31867810b8fc0942713eb Mon Sep 17 00:00:00 2001 From: wycats Date: Wed, 4 Aug 2010 03:21:37 -0700 Subject: [PATCH] If a file is in the load path, require it without its full path (in more places) --- activesupport/lib/active_support/dependencies.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 1b93eac7ee66..198c124292a8 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -388,8 +388,13 @@ def loadable_constants_for_path(path, bases = autoload_paths) end # Search for a file in autoload_paths matching the provided suffix. - def search_for_file(path_suffix) - path_suffix = path_suffix.sub(/(\.rb)?$/, ".rb") + def search_for_file(file) + path_suffix = file.sub(/(\.rb)?$/, ".rb") + + $:.each do |root| + path = File.join(root, path_suffix) + return file if File.file?(path) + end autoload_paths.each do |root| path = File.join(root, path_suffix)