This project is archived and is in readonly mode.
Regexp routing problems in 2.2.2 since 2.1.0
Reported by Wildgoose | February 5th, 2009 @ 06:06 PM
Hi, just upgraded an app from Rails 2.1.0 to 2.2.2 and finding some of my routes stopped working
URL which doesn't match is: http://blah/blog/auth/login
Route is: map.connect 'blog/:controller/:action/:id', :requirements => {:controller => /(auth|asdf)/}
In fact, neither does this match: map.connect 'blog/:controller/:action/:id', :requirements => {:controller => /(auth)/}
But this does: map.connect 'blog/:controller/:action/:id', :requirements => {:controller => /auth/}
So the problem seems to be that "( )" syntax is breaking the regexp parsing. Curiously though the regexp does work for link generation, it's only route recognition which breaks
Can anyone give me a quick workaround for this, quite a lot or routes to alter otherwise...
Comments and changes to this ticket
-
DHH February 6th, 2009 @ 01:43 PM
- Assigned user set to Michael Koziarski
-
Andrew White February 7th, 2009 @ 02:58 PM
- Tag set to actioncontroller, actionpack, patch, routing
The cause of this is that ControllerSegment is hard coded to return number of captures as 1 and it wraps the regexp in its own set of parentheses.
Attached is a patch to fix this (test included). There's a related ticket that fixes a similar bug with path segments as well.
-
Wildgoose February 7th, 2009 @ 09:34 PM
Thankyou - much appreciated. Any chance we might see this in the next release?
-
Michael Koziarski February 7th, 2009 @ 10:14 PM
- Milestone cleared.
-
Repository February 22nd, 2009 @ 02:42 AM
- State changed from new to committed
(from [f7a0a394f48a0f21e686f891546d17ce33c7840e]) Remove hardcoded number_of_capturesin ControllerSegment to allow regexp requirements with capturing parentheses
Signed-off-by: Michael Koziarski michael@koziarski.com [#1887 state:committed] http://github.com/rails/rails/co...
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1887 Regexp routing problems in 2.2.2 since 2.1.0 Signed-off-by: Michael Koziarski michael@koziarski.com [#...