Module: TableFor::Helper
- Defined in:
- lib/table_for/helper.rb
Instance Method Summary collapse
-
#table_for(model_class, records, html = {}, &block) ⇒ Object
Create a html table for records, using model class for naming things.
Instance Method Details
#table_for(model_class, records, html = {}, &block) ⇒ Object
Create a html table for records, using model class for naming things.
Examples:
table_for Product, @products do |table| table.head :name, :size, :description, :price table.body do |row| row.cell :name row.cells :size, :description row.cell number_to_currency(row.record.price) end table.foot do link_to "Add product", new_product_path end end
table_for Product, @products do |table| table.columns :name, :size, :description, :price table.foot do link_to "Add product", new_product_path end end
Returns:
A string containing the html table
(Call this method from your erb templates by wrapping each line in <%= %> or <% %>)
32 33 34 |
# File 'lib/table_for/helper.rb', line 32 def table_for(model_class, records, html = {}, &block) Table.new(self, model_class, records, html, block).render end |