Route helper uses . instead of / #4245

calvincorreli opened this Issue Dec 31, 2011 · 3 comments

2 participants


Hi @tenderlove,

Thanks a lot for fixing #4164 ...

now there's a new problem, illustrated in the updated app at:

Here are my routes, roughly lifted from my actual app:

resources :purchases
match 'purchase/:product_id' => 'purchases#new', :as => :new_purchase
match 'purchase/:product_id' => 'purchases#new', :as => :correct_new_purchase

Here is the test that fails:

assert_equal correct_new_purchase_url(products(:one)), new_purchase_url(products(:one))

which outputs:

  1) Failure:
test_new_purchase_url(ModelsControllerTest) [/Users/lars/Sites/routes-test/test/functional/models_controller_test.rb:5]:
<""> expected but was

So the URL because purchase.:product_id instead of purchase/:product_id.

No idea why.

Happy new year, you fine people! :)


Ruby on Rails member

Looks like this is due to 71d769e. Basically a similar issue to #4164 where the same named route is being defined multiple times. I'll revert that commit on 3-2-stable, but it will remain on master as the rule should be "first one wins".

Ruby on Rails member

This is fixed in e912211 and 63f7a61

@tenderlove tenderlove closed this Jan 3, 2012

Thanks, Aaron. Confirmed fixed.

@wkj wkj pushed a commit that referenced this issue Nov 7, 2013
@tenderlove tenderlove When generating routes, the last defined named route wins. This is in
contrast to route recognition where the first recognized route wins.
This behavior will not exist in Rails 4.0.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment