What is difference between render & redirect methods?

Hi,
Thest are two methods:-

  1. redirect_to :action => ‘list’
  2. render :action => ‘list’

what is difference between these two methods???

Thanks.
Prash

Am Mittwoch, den 22.03.2006, 10:53 +0100 schrieb Prashant T.:

Hi,
Thest are two methods:-

  1. redirect_to :action => ‘list’
  2. render :action => ‘list’

what is difference between these two methods???

redirect_to :action => ‘list’ forces the clients browser to request the
list action.

render :action => ‘list’ will render the template list.rhtml without
calling or redirecting to the list action.

Norman T.

http://blog.inlet-media.de

On Mar 22, 2006, at 1:53 AM, Prashant T. wrote:

Thest are two methods:-

  1. redirect_to :action => ‘list’

This causes an HTTP redirect to be returned to the browser,
which then fetches the new URL.

  1. render :action => ‘list’

This causes a ‘server side’ redirect, and causes
the other action to be executed without the browser
knowing anything about the change.

what is difference between these two methods???


– Tom M.

On Mar 22, 2006, at 11:21, Tom M. wrote:

This causes a ‘server side’ redirect, and causes
the other action to be executed without the browser
knowing anything about the change.

Almost. The action is not executed, only the corresponding template
list.rhtml is rendered as if the call was

render :view => 'list' # imaginary API

being equivalent to

render :template => "#{controller_name}/list.rhtml"

modulus the template extension. It could even happen that the list
action renders something else.

Server-side “redirects” are done with render_component.

– fxn

Xavier N. wrote:

render :view => ‘list’ # imaginary API

being equivalent to

render :template => “#{controller_name}/list.rhtml”

modulus the template extension. It could even happen that the list
action renders something else.

Server-side “redirects” are done with render_component.

Hmm, I never knew this… seems like an unfortunate decision, bound to
create confusion.

b

Am Mittwoch, den 22.03.2006, 02:21 -0800 schrieb Tom M.:

On Mar 22, 2006, at 1:53 AM, Prashant T. wrote:

  1. render :action => ‘list’

This causes a ‘server side’ redirect, and causes
the other action to be executed without the browser
knowing anything about the change.

That’s wrong. The action never gets called. Only the template for that
action is rendered.

http://api.rubyonrails.com/classes/ActionController/Base.html#M000178


Norman T.

http://blog.inlet-media.de

On Mar 22, 2006, at 18:21, Tom M. wrote:

I hate it when I do that! :slight_smile:
Heh, nevermind, I learnt it the hard way a while back :-).

– fxn

On Mar 22, 2006, at 11:21, Tom M. wrote:

This causes a ‘server side’ redirect, and causes
the other action to be executed without the browser
knowing anything about the change.

On Mar 22, 2006, at 2:41 AM, Xavier N. wrote:

Almost. The action is not executed, only the corresponding template
list.rhtml is rendered as if the call was

On Mar 22, 2006, at 2:37 AM, Norman T. wrote:

That’s wrong. The action never gets called. Only the template for that
action is rendered.

Peak Obsession

Thanks for the corrections, Xavier and Norman!

I hate it when I do that! :slight_smile:


– Tom M.