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 |
# 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() @table = table build_colgroups rows(*attrs) end |
#row(*args, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_admin/views/components/attributes_table.rb', line 23 def row(*args, &block) title = args[0] = args. classes = [:row] if [:class] classes << [:class] elsif title.present? classes << "row-#{title.to_s.parameterize(separator: "_")}" end [:class] = classes.join(" ") @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
19 20 21 |
# File 'lib/active_admin/views/components/attributes_table.rb', line 19 def rows(*attrs) attrs.each { |attr| row(attr) } end |