Class: ActiveAdmin::Views::AttributesTable
- Defined in:
- lib/active_admin/views/components/attributes_table.rb
Instance Method Summary collapse
Instance Method Details
#build(obj, *attrs) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_admin/views/components/attributes_table.rb', line 8 def build(obj, *attrs) @collection = Array.wrap(obj) @resource_class = @collection.first.class = {} [:for] = @collection.first if single_record? super() add_class "attributes-table" @table = table build_colgroups rows(*attrs) end |
#row(*args, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/active_admin/views/components/attributes_table.rb', line 24 def row(*args, &block) title = args[0] = args. ["data-row"] = title.to_s.parameterize(separator: "_") if title.present? @table << tr() do th do header_content_for(title) end @collection.each do |record| td do content_for(record, block || title) end end end end |
#rows(*attrs) ⇒ Object
20 21 22 |
# File 'lib/active_admin/views/components/attributes_table.rb', line 20 def rows(*attrs) attrs.each { |attr| row(attr) } end |