Sha256: cb735ce11fca96f711255433237dfee09547be4e824323b2f8ad1549faaf21f5

Contents?: true

Size: 825 Bytes

Versions: 5

Compression:

Stored size: 825 Bytes

Contents

module AdministrateExportable
  module Exporter
    extend ActiveSupport::Concern

    included do
      exportable
    end

    class_methods do
      def exportable
        define_method(:export) do
          search_term = params[:search].to_s.strip
          resources = Administrate::Search.new(scoped_resource,
                                               dashboard_class,
                                               search_term).run
          resources = apply_collection_includes(resources)
          resources = order.apply(resources)

          csv_data = ExporterService.csv(dashboard, resource_class, resources)

          respond_to do |format|
            format.csv { send_data csv_data, filename: "#{resource_name.to_s.pluralize}-#{Date.today}.csv" }
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
administrate_exportable-0.5.0 lib/administrate_exportable/exporter.rb
administrate_exportable-0.4.0 lib/administrate_exportable/exporter.rb
administrate_exportable-0.3.1 lib/administrate_exportable/exporter.rb
administrate_exportable-0.2.0 lib/administrate_exportable/exporter.rb
administrate_exportable-0.1.3 lib/administrate_exportable/exporter.rb