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.

This project is archived and is in readonly mode.

Rails.application.routes.recognize_path returning incorrect hash

#5678

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

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

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. andy (at stonean)
    andy (at stonean)
    • Title changed from Rails.application.routes.recognize_path returning invalid hash to Rails.application.routes.recognize_path returning incorrect hash

    September 21st, 2010 @ 11:16 PM

  2. David Trasbo
    David Trasbo
    • 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.

    September 23rd, 2010 @ 09:20 AM

  3. andy (at stonean)
    andy (at stonean)

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

    Thank you for the response and explanation.

    September 23rd, 2010 @ 02:15 PM