Class: AskIt::AttemptsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- AskIt::AttemptsController
- Defined in:
- app/controllers/ask_it/attempts_controller.rb
Overview
Handles creation and management of survey attempts
Instance Method Summary collapse
- #create ⇒ Object
-
#new ⇒ Object
Handles creation and management of survey attempts helper ‘ask_it/surveys’ include AskIt::SurveysHelper.
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/ask_it/attempts_controller.rb', line 17 def create @survey = Survey.active.last @attempt = @survey.attempts.new(attempt_params) @attempt.participant = current_user # Adjust as needed if @attempt.save redirect_to new_ask_it_attempt_path, notice: t('.success') else flash.now[:error] = @attempt.errors..join(', ') render :new end end |
#new ⇒ Object
Handles creation and management of survey attempts helper ‘ask_it/surveys’ include AskIt::SurveysHelper
10 11 12 13 14 15 |
# File 'app/controllers/ask_it/attempts_controller.rb', line 10 def new @survey = Survey.active.last @attempt = @survey.attempts.new @attempt.answers.build @participant = current_user # Adjust as needed end |