Method: ActiveAdmin::Views::TableFor#column

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

#column(*args, &block) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/active_admin/views/components/table_for.rb', line 34

def column(*args, &block)
  options = default_options.merge(args.extract_options!)
  title = args[0]
  data = args[1] || args[0]

  col = Column.new(title, data, @resource_class, options, &block)
  @columns << col

  # Build our header item
  within @header_row do
    build_table_header(col)
  end

  # Add a table cell for each item
  @collection.each_with_index do |resource, index|
    within @tbody.children[index] do
      build_table_cell col, resource
    end
  end
end