class ActiveAdmin::Views::IndexAsTable


end
end
column :some_secret_data
if can? :manage, Post
column :title, :sortable => false
index do
For example, if you were using CanCan:
easily do things that show or hide columns based on the current context.
The entire index block is rendered within the context of the view, so you can
== Showing and Hiding Columns
end
column :title, :sortable => false
index do
You can turn off sorting on any column by passing false:
end
column :title, :sortable => ‘categories.name’
index do
and the attribute separated by a dot:
You can also sort using an attribute on another table by passing the table name
end
end
link_to post.title, admin_post_path(post)
column “Title”, :sortable => :title do |post|
index do
Otherwise, any attribute that the resource collection responds to can be used.
By default, this is the column on the resource’s table that the attribute corresponds to.
is the attribute which gets used to sort objects using Active Record.
If a column is defined using a block, you must pass the key to turn on sorting. The key
Active Admin a hint for how to sort the table.
sortable by default. If you are creating a custom column, you may need to give
When a column is generated from an Active Record attribute, the table is
== Sorting
end
end
link_to “View”, admin_post_path(post)
column “Actions” do |post|
column :title
selectable_column
index do
Alternatively, you can create a column with custom links:
end
default_actions
column :title
selectable_column
index do
To setup links to View, Edit and Delete a resource, use the default_actions method:
the block as an argument.
The block gets called once for each resource in the collection. The resource gets passed into
end
end
link_to post.title, admin_post_path(post)
column “Title” do |post|
selectable_column
index do
within the context of the view for each of the objects in the collection.
The column method accepts a block as an argument which will then be rendered
link to the posts admin screen.
specific code. For example, say we wanted a colum called Title which holds a
Sometimes calling methods just isn’t enough and you need to write some view
end
column “My Custom Title”, :title
selectable_column
index do
If the default title does not work for you, pass it as the first argument:
end
column :title
selectable_column
index do
column method:
To display an attribute or a method on a resource, simply pass a symbol into the
== Defining Columns
displayed.
show, edit and delete the object. There are many ways to customize what gets
By default, the index page is a table with each of the models content columns and links to
= Index as a Table

def self.index_name

def self.index_name
  "table"
end

def build(page_presenter, collection)

def build(page_presenter, collection)
  table_options = {
    :id => "index_table_#{active_admin_config.resource_name.plural}",
    :sortable => true,
    :class => "index_table index",
    :i18n => active_admin_config.resource_class,
    :paginator => page_presenter[:paginator] != false
  }
  table_for collection, table_options do |t|
    table_config_block = page_presenter.block || default_table
    instance_exec(t, &table_config_block)
  end
end

def default_table

def default_table
  proc do
    id_column
    resource_class.content_columns.each do |col|
      column col.name.to_sym
    end
    default_actions
  end
end

def table_for(*args, &block)

def table_for(*args, &block)
  insert_tag IndexTableFor, *args, &block
end