Search code examples
ruby-on-railsrubybyebug

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


I am using inline byebug to stop the program execution and debug, from rails console or from a running rails server.

I have to debug a very repetitive loop, and I need to put a byebug in the middle of that loop.

After debugging, it seems my options are either to keep pressing c until I can get out of my loop, or abort the console execution execution with exit or something similar. But then I need to reload the whole environment.

Is it possible to just tell byebug to skip next byebug lines until the request (rails server) or until the command (rails console) finishes ?


Solution

  • I do this a couple ways:

    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 before the loop, set a breakpoint using b <line_number>. You can clear the breakpoint later at one of the prompts.