I have been thinking from the very start what is the difference between the two? when i just heard this question(refer the heading my dear). and the answer is the 'browser', yes!! the browser...
Redirect means from one controller/action to another controller/action via browser meaning a 302 response is sent after evaluation completes for the first controller/action pair and then the new controller/action is called from the browse( one can see the url changing as a result of this in the address bar)
[this Gyan is achieved by
redirect_to(options = {}, response_status = {})Redirects the browser to the target specified in options.
&
Forward means hopping to new controller/action from the correct place without going to browser.
but does rails ever legally allowed any thing like forward.. i personally don't think so... (because either i am not aware of it or rails don;t have it) :))
in that case how to implement this forwarding thing(which as such don't exist)
two ways that i can figure it out to achieve is..
1) using "render" i.e by calling some desirable template or other render option(s) for the current controller/action (but issue arises when one need to render action of some other controller, ya ya i know in rails you have your own pilot seat so go ahead :) )
2) is using normal function call i.e calling the action defined as function(with override/non overrides params) and here also drawback is same... but remember to use return after that otherwise DoubleRenderError is for you :)
and quest is on and rest will become history very soon....
No comments:
Post a Comment