How do I use the keyboard to break into ruby-debug running a rails app?

好久不见. 提交于 2020-01-04 02:58:25

问题


I'm running ruby-debug with bundle exec rdebug script/server on Rails 2.3. When I press Ctrl-C, it exits the entire program and the debugger. I want it to stop execution of the program and bring me into a debugger session.

I tried catch Interrupt but it didn't work. Is there an exception that gets called when I stop rails with Ctrl-C that would be good to use for this purpose? Or is there another way?

What I want is the equivalent of pressing the Break (pause) button in Visual Studio (I haven't yet done this with a Rails IDE).


回答1:


I recommend pry over ruby-debug. Install the gem and then you can just stick this into your code where you want to debug:

binding.pry



回答2:


you should just drop a debugger line in your code, this will automatically create a debugging session.



来源:https://stackoverflow.com/questions/8750280/how-do-i-use-the-keyboard-to-break-into-ruby-debug-running-a-rails-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!