Project

ez_table

0.0
No commit activity in last 3 years
No release in over 3 years
Create Table easily for Rails app
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

> 3.0.0
 Project Readme

EasyTable

This project rocks and uses MIT-LICENSE.

Installation

  gem 'nie_easy_table',  require: 'easy_table'

Usage

Run the generator:

rails g easy_table:install

this will create a initializer file named easy_table.rb, which you can config some html option for your table also lib/templates/slim/scaffold/index.html.slim will be created, you can modify it to adapt your app

To Start using easy_table, you just have to use the easy_table_for helper

  = easy_table_for(@users) do |t|
    - t.td :id
    - t.td :name,  header: 'user name'
    - t.action do |user|
      = link_to "View User", user_path(user)

You can custom the td(column) output with a block,

  - t.td(:name) { |user| "Hello #{user.name}"}

You can provide a model_class option for easy_table_for helper,

  = easy_table_for(@users , model_class: User)

then the table header will using User.human_attribute_name(attr) for output

if the current controller is UsersController, the model_class can be omitted.

TODO

  • I18n header
  • custom header using options
  • guess model_class from current controller
  • guess model_class from current controller, with namespace
  • custom column using block
  • custom column using class
  • add action column
  • specify multiple columns using :tds
  • config for action_column
  • config options for single column