Take the 2-minute tour ×

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).

share|improve this question
And at what point do you plan on pressing that pause button? I doubt you are fast enough to catch rails inside one of your action methods.. You can use the debugger command in your code to create a breakpoint - but breaking like in VS with the pause button is pretty much useless in a Web-App –  Tigraine Jan 5 '12 at 21:59
Hmm, maybe a dev-only rack middleware to call debugger (which I already knew about, thx) in response to a certain API call that I call with CURL, would be an adequate solution. But I'm planning to do it so I can use rdb's interface to set a breakpoint, so it doesn't have to be at a certain time. It just has to not stop the program. –  Ben Atkin Jan 6 '12 at 0:02
add comment

2 Answers

up vote 3 down vote accepted

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

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer


