0.0
No commit activity in last 3 years
No release in over 3 years
Spectabular provides a helper method which turns ActiveModel resources into tabular displays. It provides some minimal customization options.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 3.0
 Project Readme

#Spectabular

Spectabular provides a helper method which turns ActiveModel resources into tabular displays. It provides some minimal customization options.

Compatibility

Spectabular 2 is only compatible with Rails 3.0 and above. It has been tested on Rails 3.1 and 3.2.

If you are using Rails 2, please use Spectabular 1 (Rails-2 branch).

Installation

In your Rails application, add the following line to your Gemfile

  gem 'spectabular', :git => 'git://feldpost@github.com/feldpost/spectabular.git'

Run bundle install.

Usage

Assuming you have this in your controller:

@articles = Article.all

In your views:

Default:

  table_for :articles

Generates table with all content columns.

Specify columns to use:

  table_for :articles, :title, :description

Only shows the title and description attributes.

Specify column headers and content to use:

  table_for :articles,
            "Title" => :helper_method,
            "Description" => Proc.new {|record| record.description }

You can specify a helper method or block to be called. Both block and helper method take one argument, the record being passed to the table row.

Note for Ruby 1.8

Because Hashes in Ruby 1.8 are not ordered, in the above example the column order is not guaranteed. Thus, you can number your columns as such:

  table_for :articles,
            "1-Title" => :helper_method,
            "2-Description" => Proc.new {|record| record.description }

The numeration markers are removed and column order is maintained. This is not necessary if you are using Ruby 1.9.