Class: Taskables::Questions::AnswersController

Inherits:
ApplicationController
  • Object
show all
Includes:
Tasuku::Concerns::Redirectable
Defined in:
app/controllers/tasuku/taskables/questions/answers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/tasuku/taskables/questions/answers_controller.rb', line 9

def create
  answer = Taskables::Question::Answer.new

  answer_params[:option_ids].each do |num|
    answer.votes.build option_id: num
  end

  answer.author = send Tasks.config.author

  respond_to do |format|
    if answer.save
      format.html { redirect_to redirect_path_for(answer) }
    else
      format.html { redirect_to :back, alert: answer.errors.full_messages.to_sentence }
    end
  end
end