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