This project is archived and is in readonly mode.

#1261 ✓duplicate

Route recognition incorrectly reports NotImplemented when using extended recognition conditions

Reported by sds | October 24th, 2008 @ 07:00 AM | in 2.x

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 = {|verb| routes.find {|r| r.recognize(path, :method => verb)}}

To this:

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

I attach a patch for this.

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>

People watching this ticket