Difference between render and redirect_to

Difference between render and redirect_to

I was doing a rails course for progate, and I was wondering about the difference between render and redirect_to, so I will summarize the difference for myself.

the difference

-Render: Specify the view file directly. You do not have to go through other actions. Variables in actions that specify render can be used in other views ・ Redirect_to: Specify URL Transfer to another URL

How to write

render (folder / file) The first / is not required because it is a folder name


render("users/edit")

redirect_to ("/ URL / ~ / ~") First / Yes


redirect_to("/users/#{@user.id}")

Difference in movement

-Render: controller → view -Redirect_to: controller-> URL-> route-> controller-> view

The process that render specifies a view file and displays it redirect_to is the same process as receiving an HTTP request on the browser

Use properly

-Render: Used when you want to take over the previous data without updating -Redirect_to: Requires controller processing such as data deletion and update

Recommended Posts

Difference between redirect_to and render
Difference between redirect_to and render
Difference between render and redirect_to
Difference between render and redirect_to
Difference between render and redirect_to
Difference between render method and redirect_to
[rails] Difference between redirect_to and render
[Rails] Difference between redirect_to and render [Beginner]
Difference between render and redirect_to, need for arguments
[Rails] I investigated the difference between redirect_to and render.
Difference between vh and%
Difference between i ++ and ++ i
Difference between product and variant
[Java] Difference between == and equals
Difference between puts and print
Difference between CUI and GUI
Difference between variables and instance variables
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between ArrayList and LinkedList
Difference between List and ArrayList
Difference between .bashrc and .bash_profile
Difference between StringBuilder and StringBuffer
[Rails] Display error message-Differences between render and redirect_to, flash-
[Rails] What is the difference between redirect and render?
[Ruby] Difference between get and post
Difference between instance method and class method
Difference between interface and abstract class
Difference between == operator and equals method
[Java] Difference between Hashmap and HashTable
[Terminal] Difference between irb and pry
JavaServlet: Difference between executeQuery and executeUpdate
[Ruby] Difference between is_a? And instance_of?
Difference between == operator and eqals method
Rough difference between RSpec and minitest
Proper use of redirect_to and render
Understand the difference between each_with_index and each.with_index
Difference between instance variable and class variable
[JAVA] Difference between abstract and interface
Difference between Thymeleaf @RestController and @Controller
Difference between Stream map and flatMap
Difference between primitive type and reference type
Difference between string.getByte () and Hex.decodeHex (string.toCharaArray ())
[Java] Difference between Closeable and AutoCloseable
[Java] Difference between StringBuffer and StringBuilder
[Java] Difference between length, length () and size ()
[Android] Difference between finish (); and return;
[Rails] Differences between redirect_to and render methods and how to output render methods
Note: Difference between Ruby "p" and "puts"
Difference between final and Immutable in Java
Rails render redirect_to
Difference between Ruby instance variable and local variable
Difference between pop () and peek () in stack
Difference between getText () and getAttribute () in Selenium
About the difference between irb and pry
Difference between "|| =" and "instance_variable_defined?" In Ruby memoization
Difference between EMPTY_ELEMENTDATA and DEFAULTCAPACITY_EMPTY_ELEMENTDATA in ArrayList
Difference between addPanel and presentModally of FloatingPanel
[Ruby] Difference between print, puts and p
[Java] Difference between Intstream range and rangeClosed
Difference between int and Integer in Java