Disable CSV Download in Active Admin

I use the Active Admin gem, and I would like to hide or remove links on the index page of each model, allowing users to upload data in CSV, XML or JSON format. Is there any way to do this?

+5
source share
5 answers

The index method now has an option :download_links, so you can omit the download links if you want.

For instance:

ActiveAdmin.register Post do
  index :download_links => false do
    # whatever
  end
end
+15
source

An alternative to css fix above is this monkey patch:

module ActiveAdmin
  module Views
    class PaginatedCollection
      def build_download_format_links(*args)
        ''
      end
    end
  end
end
+2
source

ActiveAdmin . CSS.

app/assets/stylesheets/active_admin.css.scss

.index #active_admin_content #index_footer {
  color: white;  // Hides the 'Download text'. Pagination links are styled on their own
  a {
    display: none; // Hides the CSV .. links
  }
}
+1

, . .

ActiveAdmin.register Post do
  index :download_links => false do
    column :title
    column :body
  end
end

. , ,

index download_links: false
index do
  column :title
  column :body
end
+1

Since you asked how to remove download links on each page, it is best to add the following line in the config / initializers / active_admin.rb file .

config.namespace :admin do |admin|
  admin.download_links = false
end

You can also specify which parameters you want to use to load data, for example:

config.namespace :admin do |admin|
  admin.download_links = [:pdf] # Now, it will only show PDF option.
end

Note. Remember to restart the server after changing the configuration file.

0
source

All Articles