This is probably something very simple, but I can't seem to figure out why my collection actions are not showing up. As per the documentation it seems all I need to do is call the collection_actions method in the block passed to register. I want to add an action called "Notify All" to my user's admin page. Here's the code:
ActiveAdmin.register User do
  menu :label => "Users", :priority => 3
  filter :twitter_id
  filter :facebook_id
  filter :created_at
  filter :allows_notifications
  filter :created_at
  actions :all, except: [:destroy, :new]
  collection_action :notify_all, :method => :post do
    puts "notifying...."
  end
  batch_action :flag do |selection|
    puts "flagging...."
  end
  index do
    selectable_column
    column "", :sortable => false do |user|
      "<img src='#{user.avatar_url}' alt='user avatar' style='width:24px; height:24px;'/>".html_safe
    end
    column :uuid
    column :twitter_id
    column :facebook_id
    column :allow_notifications do |user| user.allow_notifications ? "true" : "false" end
    column :blocked do |user| user.blocked ? "true" : "false" end
    column :created_at
    default_actions
  end
  form do |f|
    f.inputs :allow_notifications,:blocked
    f.buttons
  end
  show do
    attributes_table do
      row "Avatar" do |user|
        "<img src='#{user.avatar_url}' alt='user avatar'/>".html_safe
      end
      row :uuid
      row :twitter_id
      row :facebook_id
      row :allow_notifications do |user| user.allow_notifications ? "true" : "false" end
      row :blocked do |user| user.blocked ? "true" : "false" end
      row :created_at
      row "Active Events" do |user| user.active_events.size end
      row "Conversations" do |user| user.conversations.size end
      row "Comments" do |user| user.comments.size end
    end
    active_admin_comments
  end
end
I don't see the notify_all action anywhere on the users page:

The route is there though. Do I need to customize index view to add collection action?
Yes, You have to add something in user.rb config
action_item :only => :index do
  link_to('Notify All', notify_all_admin_users_path)
end
This will add a link on the title bar beside New User link
You need to modified your AA user.rb file as:
action_item do
  link_to 'Notify All', admin_notify_all_path(path according to your routes)
end
collection_action :notify_all, :method => :post do
  puts "notifying...."
end
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With