如何阻止当前请求的Rails调试器 [英] How to stop the Rails debugger for the current request
问题描述
def show
动物=动物的
调试器
#执行其他操作
end
假设我使用 - 调试器
选项启动了我的服务器,当这个页面被查看,调试器将停止循环的每次运行。
我可以键入 cont
时间停止,所以请求继续,但这是乏味的,特别是如果我们不是在这个例子中显示4次,但是400.
有没有办法让调试器继续,而不会在每个点的循环?
我目前的解决方法是重新启动服务器,但这太费时了。
只需在调试器语句中放置条件,以便仅在您想要的时候停止,例如:
调试器如果动物=='tiger'
或者如果您想仅在循环384上检查代码:
animals.each_with_index do | animal,我|
调试器如果我== 384
#做某事
结束
或放入一个可让您继续进行特别设计的变量:
continue_debugger = false
animals.each do |动物|
调试器除非continue_debugger
#在调试器类型`p continue_debugger = true`然后`c`完成
结束
Say I have a loop in my code that calls the rails debugger a few times
def show
animals = ['dog', 'cat', 'owl', 'tiger']
for animal in animals
debugger
# do something else
end
Assuming I started my server with the --debugger
option, when this page is viewed, the debugger is going to stop for every run of the loop.
I can type cont
every time it stops so the request continues, but that's tedious, especially if we're not talking about it showing up 4 times as in this example, but 400.
Is there a way to let the debugger continue without pausing at each point of the loop?
My currently workaround is restarting the server, but that's time consuming.
Just put conditions on the debugger statement so that it stops only when you want it to, e.g.:
debugger if animal == 'tiger'
or if, say, you want to examine the code only on loop 384:
animals.each_with_index do |animal, i|
debugger if i == 384
# do something
end
or put in a variable that will let you continue ad hoc:
continue_debugger = false
animals.each do |animal|
debugger unless continue_debugger
# in the debugger type `p continue_debugger = true` then `c` when done
end
这篇关于如何阻止当前请求的Rails调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!