Class: AskIt::SurveysController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/ask_it/surveys_controller.rb

Overview

Handles creation and management of surveys

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
# File 'app/controllers/ask_it/surveys_controller.rb', line 16

def create
  @survey = AskIt::Survey.new(survey_params)
  if @survey.valid? && @survey.save
    redirect_to surveys_path, notice: I18n.t('surveys_controller.create')
  else
    render :new
  end
end

#editObject



25
26
27
# File 'app/controllers/ask_it/surveys_controller.rb', line 25

def edit
  # @survey is already loaded by before_action
end

#indexObject



8
9
10
# File 'app/controllers/ask_it/surveys_controller.rb', line 8

def index
  @surveys = AskIt::Survey.all
end

#newObject



12
13
14
# File 'app/controllers/ask_it/surveys_controller.rb', line 12

def new
  @survey = AskIt::Survey.new
end

#showObject



29
30
31
# File 'app/controllers/ask_it/surveys_controller.rb', line 29

def show
  # @survey is already loaded by before_action
end

#updateObject



33
34
35
36
37
38
39
# File 'app/controllers/ask_it/surveys_controller.rb', line 33

def update
  if @survey.update(survey_params)
    redirect_to surveys_path, notice: I18n.t('surveys_controller.update')
  else
    render :edit
  end
end