Take the 2-minute tour ×

How can I start Pry in Rails/Ruby automatically when any exception occurs, at the location of the raised exception?

I have a hard to debug problem, that I can't seem to trace back to it's source, it occurs in Rails somewhere between a controller responding and a view being rendered.

I figured if I somehow got a pry (pry gem) to open up before or after the stack trace is displayed in the console I might be able to see where the issue has occurred. Is it possible to get Pry to start up automatically when an error occurs?

Or a debugger for that matter?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Use pry-rescue it does exactly what you want.

share|improve this answer
add comment

You can use pry-debugger to set breakpoints and debug in the console using pry. Another thing you can try is to use better_errors which will give you a better error page and also an interactive console.

share|improve this answer
add comment

Your Answer


