Class: HelenaAdministration::QuestionsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_breadcrumb, #set_locale

Instance Method Details

#createObject



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

def create
  @question = @question_group.questions.build question_params
  if @question.save
    flash[:success] = t 'shared.actions.created'
    respond_with @question, location: [@survey, @version, @question_group, @question]
  else
    flash[:danger] = t 'shared.actions.error'
    render 'new'
  end
end

#destroyObject



44
45
46
47
# File 'app/controllers/helena_administration/questions_controller.rb', line 44

def destroy
  flash[:success] = t 'shared.actions.deleted' if @question.destroy
  respond_with @question_group, location: [@survey, @version, @question_group]
end

#editObject



28
29
30
31
# File 'app/controllers/helena_administration/questions_controller.rb', line 28

def edit
  add_ressources
  add_breadcrumb @question.code
end

#newObject



12
13
14
15
# File 'app/controllers/helena_administration/questions_controller.rb', line 12

def new
  @question = @question_group.questions.build
  add_breadcrumb t('.new')
end

#showObject



8
9
10
# File 'app/controllers/helena_administration/questions_controller.rb', line 8

def show
  add_breadcrumb @question.code
end

#updateObject



33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/helena_administration/questions_controller.rb', line 33

def update
  if @question.update_attributes(question_params)
    flash[:success] = t 'shared.actions.updated'
  else
    flash[:danger] = t 'shared.actions.error'
    add_breadcrumb @question.code_was
  end
  add_ressources
  respond_with @question, location: [@survey, @version, @question_group, @question]
end