How to exit pry loop without disconnecting rails console

Sometimes I use binding.pry in a long loop. I can exit the loop using exit-program , but the exit rails console also.

Is there an easy way to exit a long loop without exiting the rails console ?

+5
source share
2 answers

I'm not sure if this is what you are looking for, but you can try the disable-pry , which will iterate automatically throughout the loop without leaving the session. Another option (although not big for long loops) is to use exit or Ctrl + D , which iterates through one loop of the loop. You will need to re-enter it until your cycle is complete, however this will allow you to hit another breakpoint if your goal.

For a little more control, you can add another gem, such as byebug or pry-byebug .

+3
source
 debug = true # start loop binding.pry if debug # end loop 

You can exit each iteration of the loop individually with exit . Then, when you are ready to exit debugging and continue executing the remaining code, enter debug = false . Then exit will return you to the rails console session.

0
source

Source: https://habr.com/ru/post/1243445/


All Articles