Skip to content

Instantly share code, notes, and snippets.

@pcreux
Created July 29, 2011 16:34
Show Gist options
  • Save pcreux/1114182 to your computer and use it in GitHub Desktop.
Save pcreux/1114182 to your computer and use it in GitHub Desktop.
active_admin custom collection action with filtering and sorting
ActiveAdmin.register Order do
# Export the current collection of items with filtering and sorting
# List the current collection ids
collection_action :export_txt do
render :text => collection.map { |order| order.id }.join(', ')
end
# Add a button to index page to export current collection as txt
action_item(:only => :index) do
link_to("Export TXT", export_txt_admin_orders_path(params.except("controller", "action")))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment