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.

Parameters:

  • format (Symbol)

    the mime type to add

Returns:

  • (Array)

    A copy of the updated formats array.



49
50
51
52
53
54
55
# File 'lib/active_admin/view_helpers/download_format_links_helper.rb', line 49

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



40
41
42
43
# File 'lib/active_admin/view_helpers/download_format_links_helper.rb', line 40

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