Skip to content

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

License

Notifications You must be signed in to change notification settings

seanhuber/tablifier

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published