Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform bulk actions with Active Admin

In Active Admin, is it possible to add a checkbox to each item in an index page (this isn't hard), and add some kind of menu to perform bulk actions on all selected items, like delete all selected items at once.

I can't find an other way to do this than to create a custom page, but I'd rather not do that; seems like overkill to me.

like image 474
Jasper Kennis Avatar asked Feb 11 '12 10:02

Jasper Kennis


People also ask

What is batch action in active admin?

By default, the index page provides you a “Batch Action” to quickly delete records, as well as an API for you to easily create your own. Note that if you override the default index, you must add selectable_column back for batch actions to be usable: index do selectable_column # ... end.

What is active admin?

Active Admin is a Ruby on Rails plugin for generating administration style interfaces. It abstracts common business application patterns to make it simple for developers to implement beautiful and elegant interfaces with very little effort.


1 Answers

It works using the mentioned branch, but not on a custom panel, from what I'm seeing.

We have it working on an index:

index do
    selectable_column
    column :id
    column :name

But can't make it work on a show:

panel "Children - Process Nodes" do
  text_node link_to "New", new_admin_process_node_path(:parent_id => department_node.id)
  unless department_node.children.empty?
    table_for department_node.children do 
      column :id
      column :name

selectable_column inside table_for doesn't seem to work.

undefined local variable or method `selectable_column' for #

Any idea?

Thanks

like image 200
shoegazerpt Avatar answered Oct 21 '22 05:10

shoegazerpt