This project is archived and is in readonly mode.

#4997 ✓wontfix
Jamie Hill

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

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

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".

Comments and changes to this ticket

  • Jamie Hill

    Jamie Hill June 28th, 2010 @ 07:16 PM

    • Assigned user set to “José Valim”
  • José Valim

    José Valim June 28th, 2010 @ 08:37 PM

    • 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.

  • Jamie Hill

    Jamie Hill June 28th, 2010 @ 09:29 PM

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

  • José Valim

    José Valim June 28th, 2010 @ 09:32 PM

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

  • Jamie Hill

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages