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.

[PATCH] Make redirect_to accept a symbol following the convention used with render

#4997

This patch allows a symbol to be supplied to "redirect_to" following the same convention used with "render", whereby the a symbol is assumed to be an action e.g.

redirect_to :my_action
redirect_to :my_action, :status => 307

The "redirect :back" functionality is left untouched as the check for a symbol happens after explicitly checking for ":back".

Reported by Jamie Hill · June 28th, 2010 @ 06:34 PM

State: wontfix
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Jamie Hill
    Jamie Hill
    • Assigned user set to José Valim

    June 28th, 2010 @ 07:16 PM

  2. José Valim
    José Valim
    • State changed from new to wontfix
    • Importance changed from to Low

    Hey Jamie, thanks for the patch but render and redirect_to have different semantics, they do not need to accept the same type of arguments. Besides, I usually prefer urls for redirection, it's more explicit. redirect_to :index is not as obvious as redirect_to posts_url.

    Finally, the render "new" means: render the template named "new", notice you don't need to have an action in the controller. Although the render :action => "new" syntax may cause such confusion.

    June 28th, 2010 @ 08:37 PM

  3. Jamie Hill
    Jamie Hill

    Okay, no problem. It's probably just me being lazy not wanting to type "redirect_to :action => 'my_action'" every time.

    June 28th, 2010 @ 09:29 PM

  4. José Valim
    José Valim

    Well, in Rails 3 you can easily include a module in ActionController base that handles it for you. :)

    June 28th, 2010 @ 09:32 PM

  5. Jamie Hill