Prashant Tiwari
2006-Mar-22 09:53 UTC
[Rails] 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 -- Posted via http://www.ruby-forum.com/.
Norman Timmler
2006-Mar-22 10:20 UTC
[Rails] What is difference between render & redirect methods?
Am Mittwoch, den 22.03.2006, 10:53 +0100 schrieb Prashant Tiwari:> 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 Timmler http://blog.inlet-media.de
Tom Mornini
2006-Mar-22 10:22 UTC
[Rails] What is difference between render & redirect methods?
On Mar 22, 2006, at 1:53 AM, Prashant Tiwari 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.> 2) 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 Mornini
Norman Timmler
2006-Mar-22 10:37 UTC
[Rails] What is difference between render & redirect methods?
Am Mittwoch, den 22.03.2006, 02:21 -0800 schrieb Tom Mornini:> On Mar 22, 2006, at 1:53 AM, Prashant Tiwari wrote: > > 2) 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 Timmler http://blog.inlet-media.de
Xavier Noria
2006-Mar-22 10:41 UTC
[Rails] What is difference between render & redirect methods?
On Mar 22, 2006, at 11:21, Tom Mornini 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
Ben Munat
2006-Mar-22 16:36 UTC
[Rails] What is difference between render & redirect methods?
Xavier Noria wrote:> On Mar 22, 2006, at 11:21, Tom Mornini 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.Hmm, I never knew this... seems like an unfortunate decision, bound to create confusion. b
Tom Mornini
2006-Mar-22 17:21 UTC
[Rails] What is difference between render & redirect methods?
> On Mar 22, 2006, at 11:21, Tom Mornini 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 Noria wrote:> Almost. The action is not executed, only the corresponding template > list.rhtml is rendered as if the call wasOn Mar 22, 2006, at 2:37 AM, Norman Timmler wrote:> That''s wrong. The action never gets called. Only the template for that > action is rendered. > > http://api.rubyonrails.com/classes/ActionController/Base.html#M000178Thanks for the corrections, Xavier and Norman! I hate it when I do that! :-) -- -- Tom Mornini
Xavier Noria
2006-Mar-22 17:23 UTC
[Rails] What is difference between render & redirect methods?
On Mar 22, 2006, at 18:21, Tom Mornini wrote:>> On Mar 22, 2006, at 11:21, Tom Mornini 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 Noria 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 Timmler wrote: > >> 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 > > Thanks for the corrections, Xavier and Norman! > > I hate it when I do that! :-)Heh, nevermind, I learnt it the hard way a while back :-). -- fxn