From eade64097c48eb24d78d42ddd47c6cabb6df7d5f Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 9 Feb 2023 20:57:24 +0100 Subject: [PATCH] Clear voter count when poll is reset (#21700) (#23484) When a poll is edited, we reset the poll and remove all previous votes. However, prior to this commit, the voter count on the poll was not reset. This leads to incorrect percentages being shown in poll results. Fixes #21696 Co-authored-by: afontenot --- app/models/poll.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/poll.rb b/app/models/poll.rb index 1a326e452c..af3b09315c 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -85,6 +85,7 @@ class Poll < ApplicationRecord def reset_votes! self.cached_tallies = options.map { 0 } self.votes_count = 0 + self.voters_count = 0 votes.delete_all unless new_record? end