Skip to content


Subversion checkout URL

You can clone with
Download ZIP
tag: v0.1.0
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (43 sloc) 2.55 kB


Turn objects into nicely formatted columns for easy reading

TablePrint formats an object or array of objects into columns for easy reading. To do this, it assumes the objects in your array all respond to the same methods.


# Install as a standalone gem
$ gem install table_print

# Install within rails
In your Gemfile: gem 'table_print'
$ bundle install


# Outside rails
$ irb
> require 'table_print'
> tp array_of_objects, options = {}

# Inside rails, the gem has already been required by your Gemfile so all you need to do is
$ rails c
> tp array_of_objects, options = {}

And you should see something like this:

NAME              | SUMMARY                         | TITLE
Michael Connelly  | Another book by Michael Con...  | The Fifth Witness
Manning Mardale   | From acclaimed historian Ma...  | Malcolm X
Tina Fey          | Worth it. -Trees                | Bossypants

TablePrint tries to use sensible defaults to choose the columns to show. If you're inspecting ActiveRecord objects, it uses the ActiveRecord column names. You can customize the output to show fewer columns, or show other methods you've written on your model.

# Maybe you story a user's hourly rate but you want to see their yearly income
> tp User.limit(30), {:include => :yearly_income, :except => :hourly_rate}

# Maybe all you care about is their mailing info
> tp User.limit(30), {:only => [:address, :city, :state, :zip]}

If you're not using ActiveRecord, the TablePrint default is to show all the methods on your object. Thus, the :include option is useless at the moment. You are still able to use :only and :include.

Contributing to table_print

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


Copyright © 2011 Chris Doyle. See LICENSE.txt for further details.

Jump to Line
Something went wrong with that request. Please try again.