Rails 在执行的其余部分跳过 byebug

Rails skip byebug(s) for the rest of the execution

我正在使用内联 byebug 从 rails 控制台或 运行 rails 服务器停止程序执行和调试。

我必须调试一个非常重复的循环,我需要在该循环的中间放置一个 byebug。

调试后,我的选择似乎是继续按 c 直到我可以退出循环,或者使用 exit 或类似的东西中止控制台执行。但是我需要重新加载整个环境。

是否可以告诉 byebug 在请求(rails 服务器)或命令(rails 控制台)完成之前跳过接下来的 byebug 行?

我有几种方法:

1.

large_array.each.with_index do |item, index|
  byebug if index == 0    #  or any other condition, e.g. item.some_method?
  # ...
end
  1. 循环前的byebug,使用b <line_number>设置断点。您可以稍后在提示之一处清除断点。