Skip to content

metalelf0/Rails-table-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Sample project about table data structure in Rails

This sample project is meant to show how to introduce a simple data structure to represent a table in a Rails application.

Here's how it works:

* lib/table.rb is the Table class. It has two fields (headers and rows) and two convenience methods to add headers and rows.
* app/views/shared/_table.html.erb is the partial with the logic to represent the table. It receives as a local assign the table object to draw 

* app/controllers/people_controller.rb builds a table in the index action.

* app/views/people/index.html.erb shows an example usage of the _table.html.erb partial. 

In the future I'd like to add convenience methods to build a table like this directly from an ActiveRecord model; I want to reproduce the table built by the Rails scaffold generator, but doing it automatically, so you won't need to add manually any field to the view when you add them to the model.

Also I'd like to make it quite configurable, e.g. allow adding links to edit/delete actions, filter out some attributes, configure HTML classes for representing the table and so on.

Finally, I'd love to make this all a Rails plugin, so you can easily snap it into your project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published