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.
 
 
 
 
 

39 lines
769 B

class AnswersController < ApplicationController
include QuizHelperMethods
# POST /q/:id/answer
def create
not_found unless question
@answer = Answer.find_or_initialize_by(player_id: current_player.id, node_id: question.id)
@answer.update(answer_params)
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
def update
create
end
private
# Only allow a list of trusted parameters through.
def answer_params
params.require(:answer).permit(
:value
)
end
end