Skip to content

Commit

Permalink
Revert "Named Routes shouldn't override existing ones (currently rout…
Browse files Browse the repository at this point in the history
…e recognition goes with the earliest match, named routes use the latest match)"

This reverts commit 71d769e.
  • Loading branch information
tenderlove committed Jan 3, 2012
1 parent c4a29de commit e912211
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing/route_set.rb
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/controller/routing_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit e912211

Please sign in to comment.