What is the difference between render & redirect_to in Ruby on Rails?

The redirect_to method causes the browser to redirect from one page to the other page. This is the method in the ActionController module Base class method.

Ex:-

redirect_to :action => "index"

redirect_to :back  which redirects to the back from which page the user comes. This is the (i.e :back) short form for request.env[""HTTP_REFERER]

Render method simply renders a template without calling the specified action or redirecting to the specified action.

Ex:-

render :action => "new"

No comments:

Post a Comment