Module: ActiveAdmin::ViewHelpers::DownloadFormatLinksHelper::ClassMethods

Defined in:
lib/active_admin/view_helpers/download_format_links_helper.rb

Instance Method Summary collapse

Instance Method Details

#add_format(format) ⇒ Array

Adds a mime type to the list of available formats available for data export. You must register the extension prior to adding it here.


35
36
37
38
39
40
41
# File 'lib/active_admin/view_helpers/download_format_links_helper.rb', line 35

def add_format(format)
  unless Mime::Type.lookup_by_extension format
    raise ArgumentError, "Please register the #{format} mime type with `Mime::Type.register`"
  end
  @formats << format unless formats.include? format
  formats
end

#formatsArray

A ready only of formats to make available in index/paginated collection view. formats


26
27
28
29
# File 'lib/active_admin/view_helpers/download_format_links_helper.rb', line 26

def formats
  @formats ||= [:csv, :xml, :json]
  @formats.clone
end