How do I step out of a loop with Ruby Pry?
I'm using Pry with my Rails application. I set binding.pry
inside a loop in my model to try and debug a problem. For example:
(1..100).each do |i|
binding.pry
puts i
end
When I type quit
, it goes to the next iteration and stops again. Is there a way to step out of the loop so I don't have to type quit
100 times?
Currently the only way I know how to get out of it is to use CTRL+C and restart the application.
To exit Pry unconditionally, type
exit-program
Edit from @Nick's comment: Also works:
!!!
I use:
disable-pry
This will keep the program running, but will keep it from continuing to stop execution. This is especially helpful when you are debugging in the console.
To exit everything, use:
exit!
This should ignore all proceeding bindings.