问题
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