03 July 2012

Justin Love introduced me to a really interesting gem called DrX that can visually display the internals of any ruby class, interactively!

I had some trouble getting it to work, so I’ll include my steps here:

  1. Ruby must be compiled with pthread. e.g. rvm install 1.8.7-p72 -C --enable-pthread

  2. You must have tk/tcl. This is most easily installed via ActiveState ActiveTcl. (I’m using ActiveTcl 8.5.11.1)

  3. Install graphviz brew install graphviz

  4. Now, add gem 'drx' to your Gemfile, bundle, and load your console. try ActiveRecord::Base.see for example. (I leave the gem commented out of my Gemfile except when I want to use it).

DrX console for ActiveRecord::Base DrX console for ActiveRecord::Base

Full DrX diagram of ActiveRecord::Base, you'll need to zoom in Full DrX diagram of ActiveRecord::Base, you’ll need to zoom in

Other introspection-type libraries I’m aware of (I’ll update this)