diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 8d51e82..c41fe13 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -323,7 +323,7 @@ module ActionController seen_paths = Hash.new {|h, k| h[k] = true; false} normalize_paths(paths).each do |load_path| - Dir["#{load_path}/**/*_controller.rb"].collect do |path| + Dir["#{load_path}/**/*_controller.rb"].sort_by { |path| - path.length }.collect do |path| next if seen_paths[path.gsub(%r{^\.[/\\]}, "")] controller_name = path[(load_path.length + 1)..-1] diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index f480e6d..9534b2c 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -629,6 +629,8 @@ class RoutingTest < Test::Unit::TestCase ] assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort + assert ActionController::Routing.possible_controllers.index("admin/user") < + ActionController::Routing.possible_controllers.index("user") ensure if true_controller_paths ActionController::Routing.controller_paths = true_controller_paths