[英]Ruby on rails redirect_to
what does it mean ? 这是什么意思 ? redirect_to "" and return
redirect_to“”并返回
According to the rails API docs: the return portion stops execution of anything else. 根据Rails API文档:返回部分停止执行任何其他操作。 In other words if you had the below the text would never print because of the return statement.
换句话说,如果您具有以下内容,则由于return语句,该文本将永远不会打印。
def go_home
redirect_to(:action => "home") and return
puts "This will never print"
end
In the next example and return
is called only if monkeys.nil?
在下一个示例中
and return
仅if monkeys.nil?
调用and return
if monkeys.nil?
is true. 是真的。
def do_something
redirect_to(:action => "elsewhere") and return if monkeys.nil?
render :action => "overthere" # won't be called if monkeys is nil
end
from: http://api.rubyonrails.org/classes/ActionController/Base.html 来自: http : //api.rubyonrails.org/classes/ActionController/Base.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.