Class: Admin::ImportsController

Inherits:
ForestController
  • Object
show all
Defined in:
app/controllers/admin/imports_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/admin/imports_controller.rb', line 15

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

#editObject



4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/admin/imports_controller.rb', line 4

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