Refactor voted_before_sign_in logic to avoid no-answer scenario error

This commit is contained in:
Bertocq
2017-10-06 20:07:57 +02:00
parent 81f65f1ac9
commit bfef00d478

View File

@@ -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