如何使用键盘闯入运行Rails应用程序的ruby-debug? [英] How do I use the keyboard to break into ruby-debug running a rails app?
问题描述
我正在Rails 2.3上使用 bundle exec rdebug脚本/服务器
运行ruby-debug。当我按 Ctrl-C
时,它将退出整个程序和调试器。我希望它停止程序的执行并使我进入调试器会话。
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.
我尝试了 catch中断
,但是它没有用。当我使用 Ctrl-C
停止rails时是否会发生调用异常的情况?还是有另一种方法?
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?
我想要的是等同于按Visual Studio中的Break(暂停)按钮(我尚未使用Rails IDE做到这一点) )。
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).
推荐答案
我建议撬。安装gem,然后将其粘贴到要调试的代码中即可。
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
这篇关于如何使用键盘闯入运行Rails应用程序的ruby-debug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!