Tuesday 15 September 2015

ruby on rails - what is the difference between link_to, redirect_to, and render? -


I am confused about the main difference (s) between link_to , Redirect_to and code in the rail code can anybody please explain.

link_to is used in your view, and generates HTML code for a link

  & lt;% = link_to "Google", "http://google.com"%>   

This will generate the following HTML in your view

  & lt; A href = "http://google.com" & gt; Google & lt; / A & gt;   

Your controller uses a redirect and a render to answer a request. Redirect_to will only redirect the request to a new URL, if you have any

  redirect_to "http://google.com"   

in your controller



No comments:

Post a Comment