make awesome tables
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This rails gem is used to easily display, consistently styled tables. It is still very much a work in progress.

Installation is simple.

gem install awesome_tables
# copy the base template to app/views/awesome_tables/_base.html.erb
rails g awesome_tables


In order to use an awesome_table, first you must register it in a helper. Two examples are below.

AwesomeTables.register :posts do |t|
  t.set_caption "Posts"
  t.column :published_at, :display_published_at
  t.column :post, :partial => 'awesome_tables/posts/body'
  t.column :comment_count, :comment_counter, :header_image => 'comment-grey-bubble.png'

AwesomeTables.register :users do |t|
  t.set_caption "Users"
  t.column :full_name
  t.column :login
  t.column :email
  t.column :state

Now you can use them in your views

<%= awesome_table :users, @users %>
<%= awesome_table :posts, @posts %>

There are currently 4 different ways to declare a column.

  1. t.column(:method) A plain td can be created by passing in an object attribute. The header will be a titlized version of the method name.

  2. t.column(:header_text, :method) If you want the header text to be different than the method.

  3. t.column(:header_text, :partial => 'path/to/partial) If your td data is more complex than a method name, add a partial option.

  4. You can pass a block to the call to column. I couldn't figure out how to get rails helpers to call correctly when defined inside the block so 'c' is a reference to allow you to use view helpers

t.column :full_name do |obj, c| obj.full_name +

	c.content_tag(:div, :class => 'actions') do
  	c.link_to("Edit", c.edit_admin_user_path(obj))


The :header_image option will use the image as the column header instead header text. That code and the way it is used needs some attention. Things have changed a little bit since I put that in there.

You'll need to make sure that you create an awesome tables view folder. There is a base example table contained in lib/app/views/awesome_tables.


  • tests, tests, tests

  • figure out how to change the templates so that they don't have column loops inside of the object loop

  • add more and better options support. Currently there is only a :class (and :header_image) option for columns and the way the :class option is implemented looks nasty.

  • create different formatters so awesome_tables can be used to output tables in formats other than html tables.

Copyright © 2010 Dan Engle, released under the MIT license