Sha256: a90f4e86899fc110a70d5853c19e1fe6fa778877b2809696710a746f4788245c

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

class Admin::ImportsController < Admin::ForestController
  before_action :set_import, only: [:edit]

  def edit
    authorize @import

    respond_to do |format|
      format.html
      format.csv {
        send_data @import.to_csv_template, filename: "#{@import.to_s.parameterize.underscore}-import-template.csv"
      }
    end
  end

  def create
    klass = params[:import][:model_name].constantize
    file = params[:import][:file]

    authorize klass

    Import.new(klass, file)

    redirect_to edit_admin_import_path(klass.model_name.singular), notice: "Import has been started and is being processed in the background."
  end

  private

    def import_params
    end

    def set_import
      @import = params[:id].camelcase.constantize
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forest_cms-0.98.1 app/controllers/admin/imports_controller.rb