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.

Routing :defaults option is not passed through to params

#4131

The :defaults option in routing is not passed through to the controller params.

eg.

match 'photos/:id' => 'photos#show', :defaults => { :format => 'jpg' }

does not pass :format through to path_parameters, which is accessible via params in the controller.

Originally reported by Henrique in ticket 119 in Rails Guides.

Reported by Jeroen van Dijk · March 8th, 2010 @ 05:24 PM

State: resolved
Milestone: 3.0.2
Assigned to: josh josh
Importance: Low

Activity

  1. José Valim
    José Valim
    • Milestone cleared.
    • Assigned user set to josh

    March 8th, 2010 @ 10:54 PM

  2. josh
    josh
    • State changed from new to wontfix

    :defaults was sort of deprecated even in the old dsl.

    match 'photos/:id' => 'photos#show', :format => 'jpg'
    

    should be the preferred dsl.

    March 15th, 2010 @ 02:48 PM

  3. carl
    carl

    Has the new DSL which Joshua Peek mentioned been added to the current beta of rails3? I can't seem to get it to work.

    March 22nd, 2010 @ 09:08 PM

  4. Henrique
    Henrique

    Didn't get it to work either, that was the reason for the ticket. There is no way right now to pass parameters through the routes.

    @carl do you tested against Rails edge?

    March 22nd, 2010 @ 09:26 PM

  5. Jeroen van Dijk
    Jeroen van Dijk

    I haven't had the time to see if the suggested functionality works. I hope to do that soon, but this post of Yehuda describes the deprecated dsl (with :defaults), see http://www.railsdispatch.com/posts/rails-3-makes-life-better and search for ':defaults'

    April 7th, 2010 @ 08:14 PM

  6. José Valim
    José Valim

    It seems that support for it was added later. Please do investigate. :)

    April 7th, 2010 @ 08:26 PM

  7. Jeroen van Dijk
    Jeroen van Dijk

    I have reran the tests against master and everything works. Both with :defaults and without so Yehuda's post was not incorrect after all. After a 'git blame' I found #4265 [PATCH] Defaults support for the new Router DSL which resolves this issue, here is the specific commit: http://github.com/rails/rails/commit/3d746fcdb584767c476408f395320e...

    In summary, this ticket can be closed.

    April 24th, 2010 @ 09:32 AM

  8. José Valim
    José Valim
    • State changed from wontfix to resolved

    Thanks!

    April 24th, 2010 @ 09:33 AM

  9. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM