diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index c0eb61340b..f9b0c4bb21 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -271,6 +271,9 @@ module ActionController ALLOWED_REQUIREMENTS_FOR_OPTIMISATION = [:controller, :action].to_set + mattr_accessor :generate_best_match + self.generate_best_match = true + # The root paths which may contain controller files mattr_accessor :controller_paths self.controller_paths = [] diff --git a/actionpack/lib/action_controller/routing/route_set.rb b/actionpack/lib/action_controller/routing/route_set.rb index 329ba5b9e0..8e4ed7bcf7 100644 --- a/actionpack/lib/action_controller/routing/route_set.rb +++ b/actionpack/lib/action_controller/routing/route_set.rb @@ -406,24 +406,11 @@ module ActionController # don't use the recalled keys when determining which routes to check future_routes, deprecated_routes = routes_by_controller[controller][action][options.reject {|k,v| !v}.keys.sort_by { |x| x.object_id }] - no_worries = future_routes == deprecated_routes + routes = Routing.generate_best_match ? deprecated_routes : future_routes - deprecated_routes.each_with_index do |route, index| + routes.each_with_index do |route, index| results = route.__send__(method, options, merged, expire_on) if results && (!results.is_a?(Array) || results.first) - - # Compare results with Rails 3.0 behavior - unless no_worries - future_routes.each_with_index do |route2, index2| - new_results = route2.__send__(method, options, merged, expire_on) - if new_results && (!new_results.is_a?(Array) || new_results.first) && index2 < future_routes.index(route) - ActiveSupport::Deprecation.warn "The URL you generated will use the first matching route in routes.rb rather than the \"best\" match. " + - "In Rails 3.0 #{new_results} will be generated instead of #{results}" - break - end - end - end - return results end end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index aab7f03885..e54f2f7bdf 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -2191,10 +2191,8 @@ class RouteSetTest < ActiveSupport::TestCase map.connect "/ws/people", :controller => "people", :action => "index", :ws => true end - assert_deprecated { - url = set.generate(:controller => "people", :action => "index", :ws => true) - assert_equal "/ws/people", url - } + url = set.generate(:controller => "people", :action => "index", :ws => true) + assert_equal "/ws/people", url end def test_generate_changes_controller_module diff --git a/railties/configs/initializers/new_rails_defaults.rb b/railties/configs/initializers/new_rails_defaults.rb index 8ec3186c84..c94db0a664 100644 --- a/railties/configs/initializers/new_rails_defaults.rb +++ b/railties/configs/initializers/new_rails_defaults.rb @@ -11,6 +11,8 @@ if defined?(ActiveRecord) ActiveRecord::Base.store_full_sti_class = true end +ActionController::Routing.generate_best_match = false + # Use ISO 8601 format for JSON serialized times and dates. ActiveSupport.use_standard_json_time_format = true