From bfef00d478e399160185044390a652aedc80c3fc Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 6 Oct 2017 20:07:57 +0200 Subject: [PATCH] Refactor voted_before_sign_in logic to avoid no-answer scenario error --- app/helpers/polls_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index c66db216f..b6c0518bb 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -42,7 +42,7 @@ module PollsHelper end def voted_before_sign_in(question) - current_user.current_sign_in_at >= question.answers.find_or_initialize_by(author: current_user).updated_at + question.answers.where(author: current_user).any? { |vote| current_user.current_sign_in_at >= vote.updated_at } end end