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.

Route generation error with :defaults and :via options

#5663

There seems to be a problem when we use the :defaults and :via options simultaneously to match a route. The attached unit test should not fail! Also if the routes.rb file looks like

RouteBug::Application.routes.draw do
  match '/error' => "bug#index", :defaults => {:format => "jpg"}, :via => :get
end

then

RAILS_ENV=env rails runner 'RouteBug::Application.routes.generate :controller => :bug'
raises an error in test and production mode, but not in development mode.

I tested this with ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux] compiled from source and the ubuntu lucid ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux].

Reported by BicycleRepairMan · September 19th, 2010 @ 04:14 PM

State: open
Milestone: 3.0.6
Assigned to: josh josh
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • Milestone cleared.
    • State changed from new to open
    • Assigned user set to josh
    • Importance changed from to Low

    This is another subtle Rack::Mount bug to do with key analysis. The reason it doesn't work in test or production is that the built-in info route isn't included and this is enough to trigger the bug. If you add some additional routes inside the test it passes.

    It looks as though :format is getting added to the generation_keys array because the :request_method condition is including it in required_defaults. Once you have other routes the :format key drops out of generation_keys due to the increased frequency of the :controller and :action keys.

    September 19th, 2010 @ 10:39 PM

  2. Jeremy Kemper
  3. Ryan Bigg
    Ryan Bigg
    • Tag changed from sheepskin boots, routes to routes

    Automatic cleanup of spam.

    October 16th, 2010 @ 02:22 AM

  4. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 19th, 2010 @ 08:35 AM

  5. Santiago Pastorino
  6. Santiago Pastorino
  7. Santiago Pastorino
    Santiago Pastorino
    • Milestone changed from 3.0.5 to 3.0.6

    February 27th, 2011 @ 03:15 AM