Class: HelenaAdministration::ImportSurveysController

Inherits:
ApplicationController show all
Defined in:
app/controllers/helena_administration/import_surveys_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_breadcrumb, #set_locale

Instance Method Details

#createObject

rubocop:disable Metrics/MethodLength



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/helena_administration/import_surveys_controller.rb', line 11

def create
  @import_survey_form = ImportSurveyForm.new import_survey_form_params
  if @import_survey_form.valid?
    begin
      Helena::SurveyImporter.new @import_survey_form.script
      flash[:success] = t('shared.actions.created')
      redirect_to surveys_path
    rescue StandardError => e
      @error = e

      render 'new'
    end
  else
    flash.now[:danger] = t('shared.actions.error')
    render 'new'
  end
end

#newObject



5
6
7
8
# File 'app/controllers/helena_administration/import_surveys_controller.rb', line 5

def new
  add_breadcrumb t('.import')
  @import_survey_form = ImportSurveyForm.new
end