pretty print on Rails: undefined method ‘pp’?

I was a PHP programmer before, I got used to ‘echo’ when trying to debug PHP application.
That’s why when migrating to Ruby from PHP, I used pp a lot. Although it just prints to console, it helps a lot.

But I’ve been wondering all this while, sometimes I got an application error, undefined method ‘pp’, while trying to pretty-print an object on Rails.

I never bothered to find out why, until today where I just happen to.

It turns out we have to require ‘PP’ on our code to make it works. Duh!

And make sure you use lowercase ‘pp’ if you are in a linux environment, otherwise it will say No such file to load

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.