2
3
4
5
6
7
8
9
10
|
# File 'app/helpers/collection_to_csv_helper.rb', line 2
def collection_download(collection,options={})
column_names = options[:columns].presence
associations = options[:associations].presence
link_text = options[:link_text].presence || 'Download'
klass = collection.try(:first).class
raise(RuntimeError, "#{collection} is not a ActiveRecord collection") unless klass.ancestors.include?(ActiveRecord::Base)
collection_ids = collection.map(&:id)
link_to link_text , collection2csv_path(ids: collection_ids,klass: klass,format: "csv",column_names: column_names,associations: associations)
end
|