Can IRB look good?

Professional Rails developers know that ’script/console’ is an essential tool for testing and debugging applications. However, it can be tricky to read the output of large Objects such as a query result set. Here is an example of what we typically see in an IRB result set:

To get around this, for the most part we learn little tricks like this:
print MODEL.all.to_xml
Doing the above will give you a more eye friendly xml formatted version of the contents of your Object. This works decently granted you are not overriding the “to_xml” method and serving just a few of the Object attributes. There are other time consuming ways(but sometime necessary) methods of print out debug information. One way is to write a for loop, using “puts” statements, or perhaps write a method in IRB. There is a better way.
Hirb was develop to help soften this pain. It will pretty print ActiveRecord results sets in such a way as you my see in the Mysql console.
Installation
sudo gem install cldwalker-hirb --source http://gems.github.com
Quick Start with Rails
Its easy to try hirb out with rails by doing the following:
Setup Irb
bash> script/console
Loading local environment (Rails 2.3.2)
irb>> require 'hirb'
=> []
irb>> Hirb.enable
=> nil
Usage
MODEL.all

Enjoy!









