This project is archived and is in readonly mode.
routing constraints not working properly with regex
Reported by Neeraj Singh | June 25th, 2010 @ 05:26 AM | in 3.x
class UsersController < ApplicationController
def show
render :text => params[:id]
end
end
R4963::Application.routes.draw do |map|
resources :users
match 'person/:id' => 'users#show'
end
With the above routing rule I can hit http://localhost:3000/person/ME
Now I changed the routing rules and added constraints.
R4963::Application.routes.draw do |map|
resources :users
match 'person/:id' => 'users#show', :constraints => { :id => /[A-Z]/ }
end
Now if I try to hit http://localhost:3000/person/ME I get no route matches exception.
Comments and changes to this ticket
-
Andrew White June 25th, 2010 @ 07:06 AM
- State changed from new to invalid
Because you specified a single character id with the regexp
-
Andrew White June 25th, 2010 @ 07:08 AM
To match http://localhost:3000/person/ME the routes would be:
R4963::Application.routes.draw do |map| resources :users match 'person/:id' => 'users#show', :constraints => { :id => /[A-Z]+/ } end
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>