Making the rails console output a little more pretty

Bohn picture Bohn · Jan 16, 2013 · Viewed 23.4k times · Source

a rails console output looks like this:

User.all
=> [#<User id: 1, name: "Michael Hartl", email: "[email protected]",
created_at: "2011-12-05 00:57:46", updated_at: "2011-12-05 00:57:46">,
#<User id: 2, name: "A Nother", email: "[email protected]", created_at:
"2011-12-05 01:05:24", updated_at: "2011-12-05 01:05:24">]

I was wondering if there is command that can make it easier to read? for example there was a .pretty command in MongoDB console that was formatting the output a little more eye friendly. But not sure if there is something similar in Rails or not.

Answer

valk picture valk · Mar 19, 2014

A bit more elegant shorthand:

y User.all