require 'table_helper/collection_table' # Provides a set of methods for turning a collection into a table module TableHelper # Generates a new table for the given collection. # # == Basic Example # # This example shows the most basic usage of +collection_table+ which takes # information about a collection, the objects in them, the columns defined # for the class, and generates a table based on that. # # Suppose you have a table generated by a migration like so: # # class CreatePeople < ActiveRecord::Base # def self.up # create_table do |t| # t.string :first_name # t.string :last_name # t.integer :company_id # t.string :role # end # end # end # # ...then invoking the helper within a view: # # <%= collection_table Person.find(:all) %> # # ...is compiled to (formatted here for the sake of sanity): # #
First Name | #Last Name | #Company | #Role | #||
---|---|---|---|---|---|
John | #Doe | #1 | #President | #||
Jane | #Doe | #1 | #Vice-President | #
Title | #Category | #Author | #Date Published |
# # Comments | ## Trackbacks | #
---|---|---|---|---|---|
Open-source projects: The good, the bad, and the ugly | #General | #John Doe | #23 days | #- | #- | #
5 reasons you should care about Rails | #Rails | #John Q. Public | #21 days | #- | #- | #
Deprecation: Stop digging yourself a hole | #Rails | #Jane Doe | #17 days | #- | #- | #
Jumpstart your Rails career at RailsConf 2007 | #Conferences | #Jane Doe | #4 days | #- | #- | #
Getting some REST | #Rails | #John Doe | #about 18 hours | #- | #- | #
Title | #Category | #Author | #Date Published |
# # Comments | ## Trackbacks | #
---|---|---|---|---|---|
Open-source projects: The good, the bad, and the ugly | #General | #John Doe | #23 days | #- | #- | #
5 reasons you should care about Rails | #Rails | John Q. Public | #21 days | #- | #- | #
0 | #0 | #