This project is archived and is in readonly mode.

#6498 new
Ethan

ActiveRecord::Base should be pretty-printable

Reported by Ethan | March 1st, 2011 @ 07:41 PM

Passing an ActiveRecord::Base instance (or any structure containing an activerecord - array, hash, etc) to the PP library's #pp method should result in a nicely-formatted, multi-line output of the record and its attributes. Instead, we get the single-line result of the #inspect method.

The attached #pretty_print method outputs a separated list (using PP's #seplist method) of each record attribute and its value. It's based on the default object pretty-printer built into PP, which outputs each instance variable and its value, but this instead outputs each attribute of the record and its value. The value is passed through pp so that if it is a serialized array or hash or whatever, that may be indented and split across multiple lines of its own.

No comments found

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages