I just answered a question on a quiz and the question is as follows:
Which of the following is an invalid statement regarding render and redirect_to?
render
doesn't send a new request but redirect_to
does redirect_to
doesn't send a new request but render
does render
will not cause the current action to stop executing redirect_to
will not cause the current action to stop executing I selected the Option 1 as my answer but it came out to be wrong. I checked online and found this link where it's clearly stated that redirect_to
sends a new request to browser:
There is an important difference between render and redirect_to: render will tell Rails what view it should use (with the same parameters you may have already sent) but redirect_to sends a new request to the browser.
Option two will be the right answer as in question clearly written: Which of the following is an invalid statement
As you understood and know redirect_to
send a new request but in option it says that doesn't send so it becomes invalid statement and your answer should be
redirect_to doesn't send a new request but render does
Note:
Kindly read question properly and understand it first before give the answer..
I guess you missed the invalid
word in the question, the correct answer would be Option 4
redirect_to will not cause the current action to stop executing
Option 1 render doesn't send a new request but redirect_to does
is valid, since redirect_to
sends a get request to an action of type get
, but render
just renders the view
, it has nothing to do with the other action
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.