This project is archived and is in readonly mode.
named routes does not handle parameters with a "." in the values
Reported by Jean-Marc Lagacé | September 17th, 2008 @ 07:44 PM | in 2.x
Hello,
I have the following problem with the routes... I first thought it was a mis-configuration from my part but I can reproduce it at will on a blank new application.
Let's say you have a resource called Dummy (with the routes and controller). From the console the following will fail with Rails 2.0.2, 2.1.0 and 2.1.1:
app.dummy_path(:id=>"a-sd.ef")
app.dummy_path("a-sd.ef")
All of those generates the same message:
ActionController::RoutingError: dummy_url failed to generate from {:controller=>"dummies", :action=>"show", :id=>"a-sd.ef"}, expected: {:controller=>"dummies", :action=>"show"}, diff: {:id=>"a-sd.ef"}
from d:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1415:in `raise_named_route_error'
from d:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1379:in `generate'
from d:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:124:in `rewrite_path'
from d:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:103:in `rewrite_url'
from d:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:81:in `rewrite'
from d:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/integration.rb:214:in `url_for'
from (eval):17:in `dummy_path'
from (irb):9
Comments and changes to this ticket
-
Jean-Marc Lagacé September 17th, 2008 @ 07:46 PM
- Title changed from named routes does not handle parameters with a "." in the values to why it is important (well at least to me)
My urls contains the user name of the users on the site. I am allowing the "." as part of the name...
I can disable that feature but it's a bit silly a simple "." would crash it
-
Jean-Marc Lagacé September 17th, 2008 @ 07:46 PM
- Title changed from why it is important (well at least to me) to named routes does not handle parameters with a "." in the values
-
Pratik December 20th, 2008 @ 04:25 PM
- Assigned user set to Michael Koziarski
- State changed from new to incomplete
Could you submit a failing test case please ?
-
Jean-Marc Lagacé December 21st, 2008 @ 08:45 PM
Hi Micheal,
While putting a failing test case in place I found a way to make it work without changing any of the ActionPack code. A few reasons motivated trying to find an alternative... the main one is that the decimal point allows the Route to determine if there is a format present in the URL when parsing it.
Using the :requirements parameter of the route configuration I was finally able to put an email address as part of a named route.
So... should I document it through a test... how should we proceed?
thanks!
Jean-Marc
-
Ryan Bigg April 11th, 2010 @ 02:05 AM
- State changed from incomplete to wontfix
The idea here is if you want dots in your ids and you're not using formats it's probably best to do something like this:
map.resources :dummies, :requirements => {:id => /[a-zA-Z0-9\.\-_]+/ }
-
Lucas Húngaro June 24th, 2010 @ 04:25 PM
I think you don't understood: this works for resources but not for named routes. I have this issue on Rails 2.3.5
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
Tags
Referenced by
- 5994 routing and url_for doesn't accept dots in the custom parameters https://rails.lighthouseapp.com/projects/8994/tickets/53...