根据rails API文档:返回部分停止执行任何其他操作.换句话说,如果你有下面的文本将永远不会打印因为return语句.
def go_home
redirect_to(:action => "home") and return
puts "This will never print"
end
Run Code Online (Sandbox Code Playgroud)
在下一个示例and return中,只调用if monkeys.nil?是真的.
def do_something
redirect_to(:action => "elsewhere") and return if monkeys.nil?
render :action => "overthere" # won't be called if monkeys is nil
end
Run Code Online (Sandbox Code Playgroud)
来自:http://api.rubyonrails.org/classes/ActionController/Base.html
| 归档时间: |
|
| 查看次数: |
1774 次 |
| 最近记录: |