This project is archived and is in readonly mode.
nested resource routes not generated correctly (rails 2.3)
In rails 2.3 nested resource routes are not generated correctly. In particular, nestings show up as query params instead of nesting path segments.
This behaviour is not present in 2.2 and earlier.
map.resources :posts map.resources :authors, :has_many => :posts
In a Rails 2.3 console (incorrect behaviour):
>> include ActionController::UrlWriter >> >> url_for :controller => 'posts', :action => 'index', :author_id => '1', :only_path => true => "/posts?author_id=1"
In a rails 2.2 console (the correct behaviour):
>> include ActionController::UrlWriter >> >> url_for :controller => 'posts', :action => 'index', :author_id => '1', :only_path => true => "/authors/1/posts"
map.resources :posts line is removed from
the routes file, then the correct result is returned. This leads me
to believe that this is something to do with the algorithm that
maps params to routes. Has this changed in 2.2. > 2.3? (Just
looking for a place to start debugging)
Comments and changes to this ticket
Yeah, this is broken.
FWIW you can turn on the old routing behaviour by commenting out the
ActionController::Routing.generate_best_match = falseline in config/initializers/new_rails_defaults.rb
, which Josh introduced in commit 6fdfe4cb5fa85160f5d91bad64d5c23b4f87f820.
But Rails 3.0 does not behave this way.
[ at the moment, 3.0 has an unrelated failure, which is documented here: https://rails.lighthouseapp.com/projects/8994/tickets/3214-transact... ]
@Sam, this patch has not been applied to master since the current router will be completely rewritten. The motivation for this switch in 2.x is to easy the pain of upgrading to the new router. Rails 3.0 will not have this flag. All routes will be generated identical to the "ActionController::Routing.generate_best_match = false" behavior.
I'm still in the progress of integrating the new router into master. I expect a few more weeks of work are left.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>