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.

Namespaces routes and deprecation warnings

#3072

When I have the following routes:

map.namespace :manage do |manage|
  manage.resources :editions do |edition|
  manage.resources :events do |event|
    event.resources :editions
  end
end

And I call manage_event_editions_url(event), I get the following warning:

DEPRECATION WARNING: The URL you generated will use the first matching route
in routes.rb rather than the "best" match. In Rails 3.0
/manage/editions?event_id=26351010 will be generated instead of
/manage/events/26351010/editions.

I'm not sure whether this is a problem with the deprecation warning or with the actual routing code.

Reported by Manfred Stienstra · August 19th, 2009 @ 10:58 AM

State: invalid
Milestone: none
Assigned to: Ryan Bigg Ryan Bigg
Importance: none

Activity

  1. David Trasbo
    David Trasbo
    • Assigned user set to Ryan Bigg

    It's a problem with your routes file. You simply need to move the manage.resources :events do |event| block above the editions resource.

    Versions prior to Rails 3.0 would look through the entire routes file every time it had to generate a URL and find the "best" match. "Best" basically means that if there are two options, one with query strings and one without, the one without is preferred.

    In your case it hits it hits the manage.resources :editions and goes "hey, this route matches if we put an event_id query string at the end", where old Rails would hit the event.resources :editions line and go "hey, this is a perfect match, no query strings!"

    This ticket can be closed.

    June 20th, 2010 @ 02:40 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to invalid

    June 20th, 2010 @ 02:45 PM