Reputation: 15181
Sometimes I'm stuck in a long loop when using binding.pry
.
I can quit the loop by exit-program
, but the command exit rails console also.
Is there easy way to exit a long loop without quitting rails console
?
Upvotes: 11
Views: 4867
Reputation: 397
debug = true
# start loop
binding.pry if debug
# end loop
You can exit each loop iteration individually with exit
. Then, when you're ready to step out of debugging and continue the execution of the remaining code, enter debug = false
. Then, exit
will return you to the rails console session.
Upvotes: 0
Reputation: 180
I'm not sure this is what you're looking for but you may want to try the disable-pry
command which will automatically iterate though your entire loop without exiting the session. Another option (albeit not great for long loops) would be to use exit
or Ctrl+D which iterates through a single cycle of a loop. You would have to enter it repeatedly until your loop was complete, however it would allow you to hit another breakpoint if that's your goal.
For a little more control you may want to add another gem like byebug or pry-byebug.
Upvotes: 9