This project is archived and is in readonly mode.

#5678 ✓invalid
andy (at stonean)

Rails.application.routes.recognize_path returning incorrect hash

Reported by andy (at stonean) | September 21st, 2010 @ 11:15 PM

Simple setup:

Add a resources :users to the routes.

Fire up rails console.

Rails.application.routes.recognize_path 'users/index' => {:action=>"show", :controller=>"users", :id=>"index"}

Notice the action is "show".

Rails 3. Ruby 1.9.2p0

Comments and changes to this ticket

  • andy (at stonean)

    andy (at stonean) September 21st, 2010 @ 11:16 PM

    • Title changed from “Rails.application.routes.recognize_path returning invalid hash” to “Rails.application.routes.recognize_path returning incorrect hash”
  • David Trasbo

    David Trasbo September 23rd, 2010 @ 09:20 AM

    • State changed from “new” to “invalid”
    • Importance changed from “” to “Low”

    This is in fact the intended behavior. Rails allows the :id fragment to contain a wide range of characters, not just numbers. Perhaps index is a bit unintuitive, but imagine a request to /users/john. Clearly we don't want the john action, but a user whose name (which acts as an id in this example) is john, e.g.

  • andy (at stonean)

    andy (at stonean) September 23rd, 2010 @ 02:15 PM

    Yeah, I agree completely. Just something that caught me by surprise and, at first, appeared incorrect.

    Thank you for the response and explanation.

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>