what is the difference between link_to, redirect_to, and render?

后端 未结 9 819
余生分开走
余生分开走 2020-12-09 08:16

I am confused about the main difference(s) among link_to, redirect_to and render in Rails. anyone can please explain.

9条回答
  •  旧时难觅i
    2020-12-09 08:41

    I found a really simple explanation here

    They may seem similar to beginners but they are very different. Render tells Rails which view or asset to show a user, without losing access to any variables defined in the controller action. Redirect is different. The redirect_to method tells your browser to send a request to another URL.

提交回复
热议问题