ActiveAdmin - Customising Export Links

Removing JSON/XML

When using active admin there doesn’t seem to be an easy way to format the output of the JSON and XML export options like you can with the CSV option.

A nice patch by David Collom allows us to customise what is displayed rather then just hiding it in CSS. The patch is as follows and i just placed it at the top of one of my admin/###.rb files

1
2
3
4
5
6
7
8
9
10
11
12
13
module ActiveAdmin
  module Views
    class PaginatedCollection
      def build_pagination_with_formats(options)
        div :id => "index_footer" do
          build_pagination
          div(page_entries_info(options).html_safe, :class => "pagination_information")
          build_download_format_links([:csv]) unless @download_links == false
        end
      end
    end
  end
end

To customise what is displayed simplay change the array passing into build_download_format_links()

1
2
build_download_format_links([:csv])
build_download_format_links([:csv, :json])