This article uses Ruby 2.6.5 installed on macOS Catalina 10.15.6.
--redirect_to-> Routing-> Controller-> View. ――It's the same route as when a new request was sent. --The value of the original instance variable is __overwritten __.
redirect_to redirect path
--_ Renderer → View __ moves in this order. --There are no new requests, __ as is, go straight to the view file __. --The instance variable is not overwritten because it does not go through the controller action. --Returns to the __view file, preserving the information you entered in the form.
render :Action name
__ Whether the information is updated through routing and controllers __.
Surprisingly, you can output various views with render
.
--You can do this with the render
method.
--You can output the view file by specifying the path starting from ʻapp / views` as shown below.
render "items/show"
--You can output a file outside the application directory by using the absolute path.
render "/Users/k/projects/test/app/views/books/index.html.erb"
--The text is output as is with the : plain
option.
--Outputs an HTML string with the : html
option.
render plain: "text"
render html: helpers.tag('Hello')
https://railsguides.jp/layouts_and_rendering.html