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.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

named routes does not handle parameters with a "." in the values

#1064

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

Reported by Jean-Marc Lagacé · September 17th, 2008 @ 07:44 PM

State: wontfix
Milestone: 2.x
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. Jean-Marc Lagacé
    Jean-Marc Lagacé
    • 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

    September 17th, 2008 @ 07:46 PM

  2. Jean-Marc Lagacé
    Jean-Marc Lagacé
    • Title changed from why it is important (well at least to me) to named routes does not handle parameters with a "." in the values

    September 17th, 2008 @ 07:46 PM

  3. Pratik
    Pratik
    • Assigned user set to Michael Koziarski
    • State changed from new to incomplete

    Could you submit a failing test case please ?

    December 20th, 2008 @ 04:25 PM

  4. Jean-Marc Lagacé
    Jean-Marc Lagacé

    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

    December 21st, 2008 @ 08:45 PM

  5. Ryan Bigg
    Ryan Bigg
    • 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\.\-_]+/ }
    

    April 11th, 2010 @ 02:05 AM

  6. Lucas Húngaro
    Lucas Húngaro

    I think you don't understood: this works for resources but not for named routes. I have this issue on Rails 2.3.5

    June 24th, 2010 @ 04:25 PM