Project

tablifier

0.0
No release in over 3 years
Low commit activity in last 3 years
Converts a hash or ActiveRecord object into an html string (table).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.8
~> 4.1
~> 1.3

Runtime

>= 4.1
 Project Readme

Gem Version Build Status Coverage Status

tablifier

tablifer provides an ActionView helper method that will generate an html table displaying the attributes of an ActiveRecord (or ApplicationRecord) object or the key-value pairs of a Hash.

Screenshot

Requirements and Dependencies

Ruby version >= 2.0. This gem was written with Rails in mind, but the only real requirements are ActionView and Railties. It's been tested with ActiveRecord versions ~> 4.1 as well as ApplicationRecord for Rails 5.

Installation

Add to your Gemfile:

gem 'tablifier', '~> 1.1'

Next, bundle install. You can style generated tables yourself or use the included stylesheet (demonstrated in the above screenshot) by adding to app/assets/stylesheets/application.css:

/*
 *= require tablifier
 */

Usage

In an ERB view, call the tablify method and pass the object you'd like tablified:

<h3>A tablified hash:</h3>
<%= tablify {first_key: 'first_value', second_key: 'second_value'} %>

<h3>A tablified ActiveRecord object:</h3>
<%= tablify MyModel.first %>

License

MIT-LICENSE.