From e9122112facf56131d4bf0739382d9235582f8c0 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 3 Jan 2012 13:56:12 -0800 Subject: [PATCH] Revert "Named Routes shouldn't override existing ones (currently route recognition goes with the earliest match, named routes use the latest match)" This reverts commit 71d769e3b58cb56b4b1d5143936c65be8b27c490. --- actionpack/lib/action_dispatch/routing/route_set.rb | 2 +- actionpack/test/controller/routing_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 6d6de36a085b3..476088745647e 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -356,7 +356,7 @@ def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil conditions = build_conditions(conditions, valid_conditions, path.names.map { |x| x.to_sym }) route = @set.add_route(app, path, conditions, defaults, name) - named_routes[name] = route if name && !named_routes[name] + named_routes[name] = route if name route end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 53a50898c5b67..8cefa16ad7fb2 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -789,12 +789,12 @@ def test_named_draw assert_equal set.routes.first, set.named_routes[:hello] end - def test_earlier_named_routes_take_precedence + def test_later_named_routes_take_precedence set.draw do match '/hello/world' => 'a#b', :as => 'hello' match '/hello' => 'a#b', :as => 'hello' end - assert_equal set.routes.first, set.named_routes[:hello] + assert_equal set.routes.last, set.named_routes[:hello] end def setup_named_route_test