Skip to content

Commit

Permalink
If a file is in the load path, require it without its full path (in m…
Browse files Browse the repository at this point in the history
…ore places)
  • Loading branch information
wycats committed Aug 4, 2010
1 parent 8bf7973 commit 991cd59
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions activesupport/lib/active_support/dependencies.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 991cd59

Please sign in to comment.