You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

34 lines
707 B

class AnswersController < ApplicationController
include QuizHelperMethods
# POST /q/:id/answer
def create
not_found unless question
@answer = Answer.new(answer_params.merge(player_id: current_player.id, node_id: question.id))
respond_to do |format|
if @answer.save
current_player.update_answer_cache
format.html { redirect_to url_for(controller: 'questions', action: 'answer', id: params[:id]) }
else
format.html { render 'questions/show', status: :unprocessable_entity }
end
end
end
private
# Only allow a list of trusted parameters through.
def answer_params
params.require(:answer).permit(
:value
)
end
end