From dfa8f4590aebd51978d5da4879cb307b0f1f0551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Fri, 20 Oct 2017 16:57:41 +0200 Subject: [PATCH] Most voted fix --- app/controllers/polls/questions_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/polls/questions_controller.rb b/app/controllers/polls/questions_controller.rb index 6345773f2..e1fc73805 100644 --- a/app/controllers/polls/questions_controller.rb +++ b/app/controllers/polls/questions_controller.rb @@ -13,10 +13,9 @@ class Polls::QuestionsController < ApplicationController answer.touch if answer.persisted? answer.save! answer.record_voter_participation(token) - @question.question_answers - .where(question_id: @question, title: answer.answer) - .first - .set_most_voted + @question.question_answers.where(question_id: @question).each do |answer| + answer.set_most_voted + end @answers_by_question_id = { @question.id => params[:answer] } end