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… read them below or add one }

arcandros June 18, 2011 at 9:26 am

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

Reply

Jon Leighton June 30, 2011 at 10:26 pm

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

Reply

Jared Ning August 7, 2011 at 8:10 pm

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.

Reply

Leave a Comment

{ 1 trackback }

Previous post:

Next post: