Every time I write a process, I still get confused, so Make a note so that you can remember it immediately.
redirect_to
user_controller.rb
def ~
#processing
redirect_to("/app/posts/new")
end
Designation destination: URL(/URL/〜/〜/)
root: controller → URL → route → controller → view
Main applications: When data needs to be updated or deleted, etc. → ** When "processing with an appropriate controller is required" **
render
user_controller.rb
def ~
#processing
render("user/edit")
end
Designation destination: Directory / view
root: controller → view
Main applications: When login or input format fails, etc. → ** When "I just want to display an error" **
[Rails] Difference between render and redirect_to and proper use [Rails] Detailed method and explanation for displaying simple messages using flash messages
Recommended Posts