Project

table_for

0.0
No release in over 3 years
Renders a table for your model collection
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0.0.beta.20

Runtime

~> 3.0
 Project Readme

TableFor¶ ↑

Renders a table for your model collection. Like show_for, but for collections…

Disclaimer¶ ↑

Should not be considered stable. Briefly tested under Rails 3 running Ruby 1.8.7 and 1.9.2 and recently updated to pass tests on Ruby 2.6.0 and Rails 5 Test coverage not complete.

Installation¶ ↑

Add the below line to your gem file and run bundle install

gem "table_for"

Basic Usage¶ ↑

In your erb views:

<%= 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 %>

Or:

<%= table_for Product, @products do |table| %>
  <%= table.columns :name, :size, :description, :price %>
  <%= table.foot do %>
    <%= link_to "Add product", new_product_path %>
  <% end %>
<% end %>

The footer and rows can be filtered out through the TableFor.footer_filter/row_filter methods.

Development¶ ↑

Install with ‘bundle install` and run test with `bundle exec rspec`

Credits and contributors¶ ↑

  • Jonas Nicklas (jnicklas) who actually wrote most of the code while we pair-programmed.

  • Elabs for sponsoring with development time.

  • The authors of the show_for gem for providing the inspiration.