Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Route helper uses . instead of / #4245

Closed
calvincorreli opened this Issue · 3 comments

2 participants

@calvincorreli

Hi @tenderlove,

Thanks a lot for fixing #4164 ...

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

https://github.com/larspind/rails-3-2-routes-priority-change

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]:
<"http://test.host/purchase/980190962"> expected but was
<"http://test.host/purchase.980190962">.

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

No idea why.

Happy new year, you fine people! :)

//Lars

@tenderlove
Owner

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".

@tenderlove
Owner

This is fixed in e912211 and 63f7a61

@tenderlove tenderlove closed this
@calvincorreli

Thanks, Aaron. Confirmed fixed.

@wkj wkj referenced this issue from a commit
@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.

See:

  #4245
  #4164
63f7a61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.