Class: AskIt::AttemptsController

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

Overview

Handles creation and management of survey attempts

Instance Method Summary collapse

Instance Method Details

#createObject



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.full_messages.join(', ')
    render :new
  end
end

#newObject

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