007 RR Debugging in Ruby

by Charles Max Wood on June 16, 2011

Panelists

Items discussed in today’s episode

  • Debuggers and Tools
  • Formatting Debug Output
  • Outputting debug information
  • Other debugging tricks
    • abort_on_exception = true
    • The Ruby executable’s -d switch and the $DEBUG constant
    • Using a logger to output data from a specific piece of code
    • The debug method in Rails helpers and views
    • Using Object#freeze on to find what is modifying the object
    • Passing a dummy object that uses method_missing to output method calls and arguments
    • Do not debug alone
    • Spike the debugging, git stash the changes, write the test, unstash the changes and verify the result

Panel Picks

3 comments
Jared Ning
Jared Ning

Bundler can open up a gem in your editor as well: `bundle open name_of_gem`. Since I use Bundler for just about every project, I've gone this route as opposed to installing another gem.

Jon Leighton
Jon Leighton

Since you asked for extra debugging tips in the comments... If you ever find yourself wondering where the sodding hell that damn method is defined, on 1.9.2 you can do "method(:my_method).source_location" and get the file and line number :)

arcandros
arcandros

Fun podcast as always guys. That question on the open_gem pick at the end about how you don't change an opened gem or how you revert changes is easy to answer. A 'gem i your_gem' will revert any changes you make. It's actually a method I 've used often: Edit the gem files directly to add some debugging output or make some changes then rollback any changes with gem i. open_gem is an awesome shortcut for this method, cheers. V.-

Trackbacks

  1. [...] enough experience with it so far to form an opinion. I’ve been recommended to listen to the debugging in ruby episode, and I [...]

Previous post:

Next post: