Class: Importable::SpreadsheetsController

Inherits:
ImporterController show all
Defined in:
app/controllers/importable/spreadsheets_controller.rb

Instance Method Summary collapse

Methods inherited from ImporterController

#importer_class, #importer_name, #init_import_params, #map_specific_path, #new, #prepend_map_specific_view_path, #require_type_param, #return_url, #show

Instance Method Details

#createObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/importable/spreadsheets_controller.rb', line 3

def create
  init_spreadsheet
  init_import_params
  set_default_sheet

  if @importer.save
    set_current_step
    prepare_next_step

    if @importer.last_step?
      if @importer.import!
        notice = if @importer.sheets.one?
          "#{@type.humanize} spreadsheet was successfully imported."
        else
          "#{@importer.default_sheet} worksheet of #{@type} spreadsheet was successfully imported."
        end
        redirect_to return_url, notice: notice
        return
      end
      @importer.previous_step
    end
  end

  # if not redirected
  render action: 'new'
end