# redirect\_to or render

**URL:** <https://discuss.rubyonrails.org/t/redirect-to-or-render/25603>\
**Category:** rubyonrails-talk\
**Created:** [February 28, 2008, 10:21pm UTC](https://discuss.rubyonrails.org/t/redirect-to-or-render/25603 "2008-02-28T22:21:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaish1](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@shaish1](https://discuss.rubyonrails.org/u/shaish1)\
**Post date:** [February 28, 2008, 10:21pm UTC](https://discuss.rubyonrails.org/t/redirect-to-or-render/25603/1 "2008-02-28T22:21:20Z")

</div>

Hey, a newbie here. Can someone please give me a brief explanation whats the difference between the redirect\_to method and the render method and when should I use one instead of the other ? thnx alot !

---

<div class="post-metadata">

**Author:** ![Greg6](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@Greg6](https://discuss.rubyonrails.org/u/Greg6)\
**Post date:** [February 28, 2008, 10:25pm UTC](https://discuss.rubyonrails.org/t/redirect-to-or-render/25603/2 "2008-02-28T22:25:25Z")

</div>

redirect\_to will issue a 302 to the browser, so that the browser will issue a new request.

render will create content. You have to make sure that your controller has set up all of your variables for any render that you create.

If you are going to cross controllers, or you do not have enough information to call a particular render, then you want to use redirect\_to. If you choose between rss/html or one layout vs. another, then you can use render.

---

<div class="post-metadata">

**Author:** ![Steve\_Ross](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Steve\_Ross](https://discuss.rubyonrails.org/u/Steve_Ross)\
**Post date:** [February 28, 2008, 10:26pm UTC](https://discuss.rubyonrails.org/t/redirect-to-or-render/25603/3 "2008-02-28T22:26:42Z")

</div>

Use redirect\_to when you want the browser to receive a 302 redirect response and go to another URL. Use render when you don't need the browser to issue another request, but can render a page and return a 200. Examples:

- User fills in form in new action - Fields are filled in incompletely or incorrectly - Post goes to the create action, which understands that and renders the 'new' template again with a 200 so the user can fix errors

- User fills in form in new action - Fields are filled in correctly - Post goes to create and information is successfully added to the database - You issue a redirect to the index page (or something)
