Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable CSV downloads in Active Admin

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

like image 635
Noel H Avatar asked Jan 19 '12 15:01

Noel H


3 Answers

There is now an option :download_links on the index method, so you omit the download links if you want.

For example:

ActiveAdmin.register Post do
  index :download_links => false do
    # whatever
  end
end
like image 167
kmcphillips Avatar answered Oct 31 '22 22:10

kmcphillips


You should use it as a option of index, but do not separate it from the column functions. Use it like this.

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

Do not use it like this.This will let all your table columns is displayed, not the only that you specified by column function

index download_links: false
index do
  column :title
  column :body
end
like image 44
blio Avatar answered Oct 31 '22 23:10

blio


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

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

You can also specify where options you would like to have for downloading the data, like:

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

Note: Don't forget to restart your server after you modify a config file.

like image 32
Arslan Ali Avatar answered Oct 31 '22 23:10

Arslan Ali