Many people (including me) have complained about the lack of a good GUI debugger for Ruby. Now that some are finally getting usable, I’ve found I actually prefer IRB-style ruby-debug to a GUI.
Install the latest gem
$ gem install ruby-debug
Install the cheatsheet
$ gem install cheat $ cheat rdebug
Set autolist, autoeval, and autoreload as defaults
$ vi ~/.rdebugrc set autolist set autoeval set autoreload
Run Rails (or other app) via rdebug
$ rdebug script/server
Breakpoint from rdebug
(rdb:1) b app/controllers/my_controller.rb:10
Breakpoint in source
require 'ruby-debug' debugger my_buggy_method('foo')
(rdb:1) cat RuntimeError
Continue to breakpoint
Next Line (Step Over)
Where (Display Frame / Call Stack)
List current line
Evaluate any var or expression
Modify a var
(rdb:1) @myvar = 'foo'
There are many other commands, but these are the basics you need to poke around. Check the Cheat sheet for details.
This can also be used directly from any IDE that supports input into a running console (such as Intellij Idea).
That should get you started. So, before you stick in another ‘p’ to debug, try out ruby-debug instead!
About the Author
BiographyMore Content by Chad Woolley