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 recognition incorrectly reports NotImplemented when using extended recognition conditions

#1261

In the rails code comments it suggests that Route#recognition_conditions may be redefined by a plugin to allow for routing to depend on different and new conditions. You also modify the creation of the environment data (a hash) that feeds this in RouteSet#extract_request_environment.

I have a plugin that does this so that I can base routing decisions on the query string passed in the request (yeh, it may not necessarily be rfc compliant to do that, but I do need it).

Rails incorrectly raises NotImplemented errors when the route (with the extra conditions) does not match rather than RoutingError because the extra environment is not passed on to route recognition when testing for other HTTP verbs that might work (so those recognition tests might pass when they shouldn't).

This requires a one line fix in recognition_optimisation.rb

Change this:


        allows = HTTP_METHODS.select {|verb| routes.find {|r| r.recognize(path, :method => verb)}}

To this:


        allows = HTTP_METHODS.select {|verb| routes.find {|r| r.recognize(path, environment.merge(:method => verb))}}

I attach a patch for this.

Reported by sds · October 24th, 2008 @ 07:00 AM

State: duplicate
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik
    • Tag set to patch, routing
    • State changed from new to duplicate

    Looks like this has already been already fixed - http://github.com/rails/rails/co...

    March 6th, 2009 @ 04:59 PM