hoodwink.d enhanced

Fri Jun 2

Tip Reading Object Details in the Rails Console

By default, the Rails console (irb) echoes an #inspect dump of the result of every expression you type. This is usually what you want. But sometimes if you’re trying to look at a complex object, it can get hard to read. For those times, try:

>> puts the_object.to_yaml

The #to_yaml call gives you a readable representation of the object and “puts” returns nil, which means the console will only echo “nil” and not the object’s contents.