Class: HelenaAdministration::SurveysController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_breadcrumb, #set_locale

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/helena_administration/surveys_controller.rb', line 18

def create
  add_breadcrumb t('shared.actions.new')

  @survey = Helena::Survey.new survey_params
  if @survey.save
    flash[:success] = t 'shared.actions.created'
  else
    flash.now[:danger] = t 'shared.actions.error'
  end
  respond_with @survey
end

#destroyObject



49
50
51
52
# File 'app/controllers/helena_administration/surveys_controller.rb', line 49

def destroy
  flash.now[:success] = t 'shared.actions.deleted' if @survey.destroy
  respond_with @survey
end

#editObject



35
36
37
# File 'app/controllers/helena_administration/surveys_controller.rb', line 35

def edit
  add_breadcrumb @survey.name
end

#indexObject



9
10
11
# File 'app/controllers/helena_administration/surveys_controller.rb', line 9

def index
  @surveys = Helena::Survey.asc(:position)
end

#newObject



13
14
15
16
# File 'app/controllers/helena_administration/surveys_controller.rb', line 13

def new
  @survey = Helena::Survey.new
  add_breadcrumb t('shared.actions.new'), new_survey_path
end

#showObject



30
31
32
33
# File 'app/controllers/helena_administration/surveys_controller.rb', line 30

def show
  add_breadcrumb @survey.name
  @sessions = Helena::Session.where(survey_id: @survey.id).desc(:updated_at).page(params[:page]).per(100)
end

#updateObject



39
40
41
42
43
44
45
46
47
# File 'app/controllers/helena_administration/surveys_controller.rb', line 39

def update
  if @survey.update_attributes survey_params
    flash[:success] = t 'shared.actions.updated'
  else
    flash.now[:danger] = t 'shared.actions.error'
    add_breadcrumb @survey.name_was
  end
  respond_with @survey
end