This project is archived and is in readonly mode.

#3198 ✓invalid
Ian White

nested resource routes not generated correctly (rails 2.3)

Reported by Ian White | September 14th, 2009 @ 01:23 PM | in 2.3.6

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"

If the 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

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=""></a>


Referenced by