When working on a web app in python/flask, I am able to import pdb
at the top of a file, and then call pdb.set_trace()
somewhere in my code to "pause" the web app and open an interactive console in my terminal for debugging. I am looking for something similar in Ruby/Rails. What exists for this purpose, and how do I use it?
Asked
Active
Viewed 833 times
0

Nathan McCallum
- 237
- 1
- 4
- 18

Jason B
- 7,097
- 8
- 38
- 49
-
http://railscasts.com/episodes/280-pry-with-rails – house9 Feb 26 '14 at 06:31
-
https://github.com/rweng/pry-rails – house9 Feb 26 '14 at 06:32
2 Answers
1
Pry (and pry-remote) might be what you're looking for. I have no experience with it, but this is what it's supposed to let you do.

Philip Hallstrom
- 19,673
- 2
- 42
- 46
0
I have found a solution.
The gem debugger
is created for this purpose. To start, run
gem install debugger
After, add the line debugger
into your code to "pause" the code at that point. For example:
def hello
@users = Users.all()
debugger
end
Then, when starting the server, call it with:
rails server --debugger

Jason B
- 7,097
- 8
- 38
- 49