Method: ActiveAdmin::Views::TableFor#build

Defined in:
lib/active_admin/views/components/table_for.rb

#build(obj, *attrs) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_admin/views/components/table_for.rb', line 11

def build(obj, *attrs)
  options = attrs.extract_options!
  @sortable = options.delete(:sortable)
  @collection = obj.respond_to?(:each) && !obj.is_a?(Hash) ? obj : [obj]
  @resource_class = options.delete(:i18n)
  @resource_class ||= @collection.klass if @collection.respond_to? :klass

  @columns = []
  @tbody_html = options.delete(:tbody_html)
  @row_html = options.delete(:row_html)
  # To be deprecated, please use row_html instead.
  @row_class = options.delete(:row_class)

  build_table
  super(options)
  add_class "data-table"
  columns(*attrs)
end