Module: Voom::Presenters::Helpers::Rails::ModelTable
- Included in:
- Voom::Presenters::Helpers::Rails
- Defined in:
- lib/voom/presenters/helpers/rails/model_table.rb
Instance Method Summary collapse
-
#table_for(query_, empty_icon: 'far fa-folder-open fa-rotate-180', except: [:id, :created_at, :updated_at], timezone: nil, selectable: false, &block) ⇒ Object
Build a a table from a Rails model.
Instance Method Details
#table_for(query_, empty_icon: 'far fa-folder-open fa-rotate-180', except: [:id, :created_at, :updated_at], timezone: nil, selectable: false, &block) ⇒ Object
Build a a table from a Rails model
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/voom/presenters/helpers/rails/model_table.rb', line 7 def table_for(query_, empty_icon: 'far fa-folder-open fa-rotate-180', except: [:id, :created_at, :updated_at], timezone: nil, # The timezone to covnert _at and _on values selectable: false, &block) row1 = query_.first if row1 __columns__ = row1.class.columns table selectable: selectable do _table_header_(__columns__, except) query_.each do |item_| row do _table_row_(__columns__, block, except, item_, timezone: timezone) end end end else icon empty_icon, size: '6rem' if empty_icon body "You have no #{query_.arel_table.name.pluralize.humanize}" end end |