[英]Render and redirect_to in rails
我刚刚在测验中回答了一个问题,问题如下:
以下哪项是关于render和redirect_to的无效语句?
render
不发送新请求,但redirect_to
会发送 redirect_to
不发送新请求,但是render
render
不会导致当前动作停止执行 redirect_to
不会导致当前动作停止执行 我选择了选项1作为答案,但结果是错误的。 我在线检查了一下,发现该链接清楚地表明redirect_to
向浏览器发送了新请求:
render和redirect_to之间有一个重要的区别:render将告诉Rails应该使用哪个视图(使用您可能已经发送过的相同参数),但是redirect_to向浏览器发送一个新请求。
备选方案二将是正确的答案,明确指出:下列哪项是无效的陈述
如您所知并知道redirect_to
发送一个新请求,但是在选项中它说不发送,因此它变成无效的语句 ,您的答案应该是
redirect_to doesn't send a new request but render does
注意:
Kindly read question properly and understand it first before give the answer..
我想您错过了问题中的invalid
单词, 正确答案将是选项4
redirect_to will not cause the current action to stop executing
选项1 render doesn't send a new request but redirect_to does
有效,因为redirect_to
将get请求发送至类型为get
的操作,但是render
仅渲染view
,而与其他action
无关
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.