# Named routine alternative to redirect\_to

**URL:** <https://www.ruby-forum.com/t/named-routine-alternative-to-redirect-to/107132>\
**Category:** Rails\
**Created:** [June 18, 2007, 2:12pm UTC](https://www.ruby-forum.com/t/named-routine-alternative-to-redirect-to/107132 "2007-06-18T14:12:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [June 18, 2007, 2:12pm UTC](https://www.ruby-forum.com/t/named-routine-alternative-to-redirect-to/107132/1 "2007-06-18T14:12:56Z")

</div>

according to [Ruby on Rails — A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.](http://www.rubyonrails.org/deprecation) redirect\_to is  
deprecated. My logs say that “Instead you should use the named route  
directly,”  
But if i have an action such as

def action  
end

i thought that calling redirect\_to :action is different from just  
action(). redirect\_to :action actually sends a 302 redirect while  
action() just executes the method. Am I wrong? Any thoughts?  
Thanks

–Andrei

---

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [June 18, 2007, 2:21pm UTC](https://www.ruby-forum.com/t/named-routine-alternative-to-redirect-to/107132/2 "2007-06-18T14:21:53Z")

</div>

andreim wrote:

> according to [Ruby on Rails — A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.](http://www.rubyonrails.org/deprecation) redirect\_to is  
> deprecated. My logs say that "Instead you should use the named route

from the doc:  
redirect\_to\_path, redirect\_to\_url.  
Use redirect\_to.

it says redirect\_to\_path and \_url are deprecated, not redirect\_to  
itself.

Named routes are routes you give a name to in config/routes.rb.

i.e. map.actionname ‘/actionurl’, :controller =\> ‘mycontroller’, :action  
=\> ‘myaction’

you can then redirect\_to it by:  
redirect\_to actionname\_url
