Class: SurveysController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- SurveysController
- Defined in:
- app/controllers/surveys_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/surveys_controller.rb', line 23 def create @survey = Survey.new(params[:survey]) if @survey.save flash[:notice] = "Successfully created survey." redirect_to @survey else render :action => 'new' end end |
#destroy ⇒ Object
47 48 49 50 51 52 |
# File 'app/controllers/surveys_controller.rb', line 47 def destroy @survey = Survey.find(params[:id]) @survey.destroy flash[:notice] = "Successfully destroyed survey." redirect_to surveys_url end |
#edit ⇒ Object
33 34 35 |
# File 'app/controllers/surveys_controller.rb', line 33 def edit @survey = Survey.find(params[:id]) end |
#index ⇒ Object
2 3 4 |
# File 'app/controllers/surveys_controller.rb', line 2 def index @surveys = Survey.all end |
#new ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/surveys_controller.rb', line 12 def new @survey = Survey.new 1.times do question = @survey.questions.build 3.times { question.answers.build } end 3.times do summary = @survey.summaries.build end end |
#show ⇒ Object
6 7 8 9 10 |
# File 'app/controllers/surveys_controller.rb', line 6 def show authenticate_user! @survey = Survey.find(params[:id]) @survey_answer = SurveyAnswer.new end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/surveys_controller.rb', line 37 def update @survey = Survey.find(params[:id]) if @survey.update_attributes(params[:survey]) flash[:notice] = "Successfully updated survey." redirect_to @survey else render :action => 'edit' end end |