diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 1b93eac7ee667538bcd8318caeee88e909b7bf43..198c124292a80179214fc74a8256db1d9c682f2c 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)