Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Generate routes for nested resources with nil object

#4262

When we have nested routes like this:
map.resources :families, :has_many => :people

Inside controllers and views:
family_people_path(1) => /families/1/people
but:
family_people_path(nil) => /families//people

Is it not supposed to raise a RoutingError ?

In console it does:

include ActionController::UrlWriter
family_people_path(nil)
ActionController::RoutingError: family_people_url failed to generate from {:action=>"index", :family_id=>nil, :controller=>"people"}, expected: {:action=>"index", :controller=>"people"}, diff: {:family_id=>nil}

Reported by fuse · March 24th, 2010 @ 03:26 PM

State: committed
Milestone: 2.3.6
Assigned to: nobody
Importance: Low

Activity

  1. José Valim
    José Valim
    • Assigned user set to josh
    • Milestone cleared.

    March 26th, 2010 @ 11:05 PM

  2. Rizwan Reza
    Rizwan Reza
    • Milestone set to 2.3.6

    José, I am not sure this relates to 3.0, since his example shows map.resources ....

    March 26th, 2010 @ 11:14 PM

  3. José Valim
    José Valim
    • Assigned user cleared.

    That's true, my bad!

    March 26th, 2010 @ 11:21 PM

  4. fuse
    fuse

    You're right. To be exact I encounter this bug in 2.3.5.

    March 27th, 2010 @ 01:44 AM

  5. Santiago Pastorino
  6. Santiago Pastorino
  7. Repository
    Repository
    • State changed from open to committed

    (from [cfb31edb5441f0b12693a3b509dadf87fe1df843]) Generate routes for nested resources with nil object raise RoutingError [#4262 Generate routes for nested resources with nil object state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/cfb31edb5441f0b12693a3b509dadf...

    April 7th, 2010 @ 05:29 AM