Method: ActiveAdmin::Xls::Builder#column

Defined in:
lib/active_admin/xls/builder.rb

#column(name, &block) ⇒ Object

Add a column

Examples:

With block

xls(i18n_scope: [:rspec], header_style: { size: 20 }) do
  delete_columns :id, :created_at
  column(:author) { |post| post.author.first_name }
end

With default value

Builder.new(Post, header_style: {}, i18n_scope: i[xls post]) do
  whitelist
  column :title
end

Parameters:

  • name (Symbol)

    The name of the column.

  • block (Proc)

    A block of code that is executed on the resource when generating row data for this column.



211
212
213
214
215
216
217
218
219
220
# File 'lib/active_admin/xls/builder.rb', line 211

def column(name, &block)
  if @columns_loaded
    columns << Column.new(name, block)
  else
    column_lambda = lambda do
      column(name, &block)
    end
    @column_updates << column_lambda
  end
end