Class: RailsImporter::ImportsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/rails_importer/imports_controller.rb', line 9

def create
  @import = Import.new(import_params)
  if @import.valid?
    ImportJob.perform_later @import.importer_key, @import.filepath
    flash[:notice] = I18n.t(:processing_import, scope: :rails_importer)
    redirect_to after_import_path
  else
    render 'new'
  end
end

#newObject



5
6
7
# File 'app/controllers/rails_importer/imports_controller.rb', line 5

def new
  @import = Import.new(importer_key: @importer_class.key)
end

#sampleObject



20
21
22
23
24
25
26
27
# File 'app/controllers/rails_importer/imports_controller.rb', line 20

def sample
  file = File.open(@importer_class.sample_file)

  send_data file.read, :filename => File.basename(@importer_class.sample_file)
rescue => e
  flash[:alert] = I18n.t(:sample_file_not_available, scope: :rails_importer)
  redirect_to after_import_path
end