Class: Rapidfire::SurveysController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_administrator!

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/rapidfire/surveys_controller.rb', line 13

def create
  @survey = Survey.new(survey_params)
  if @survey.save
    respond_to do |format|
      format.html { redirect_to surveys_path }
      format.js
    end
  else
    respond_to do |format|
      format.html { render :new }
      format.js
    end
  end
end

#destroyObject



28
29
30
31
32
33
34
35
36
# File 'app/controllers/rapidfire/surveys_controller.rb', line 28

def destroy
  @survey = Survey.find(params[:id])
  @survey.destroy

  respond_to do |format|
    format.html { redirect_to surveys_path }
    format.js
  end
end

#indexObject



5
6
7
# File 'app/controllers/rapidfire/surveys_controller.rb', line 5

def index
  @surveys = Survey.all
end

#newObject



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

def new
  @survey = Survey.new
end

#resultsObject



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

def results
  @survey = Survey.find(params[:id])
  @survey_results =
    SurveyResults.new(survey: @survey).extract

  respond_to do |format|
    format.json { render json: @survey_results, root: false }
    format.html
    format.js
  end
end