about summary refs log tree commit diff
path: root/app/models/poll.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-05-26 18:05:47 +0200
committerGitHub <noreply@github.com>2022-05-26 18:05:47 +0200
commit088dc0ec5a383006952c0b15508af882a4c1109c (patch)
tree9669b88ed5a42ca254f4c092651cd4d09521820f /app/models/poll.rb
parenta4fa9e23fc1ddb42452bb8f051a31894796c8002 (diff)
Fix regression in `tootctl search deploy` caused by unloaded attribute (#18514)
Diffstat (limited to 'app/models/poll.rb')
-rw-r--r--app/models/poll.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/app/models/poll.rb b/app/models/poll.rb
index ba08309a1..1a326e452 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -39,13 +39,12 @@ class Poll < ApplicationRecord
 
   before_validation :prepare_options, if: :local?
   before_validation :prepare_votes_count
-
-  after_initialize :prepare_cached_tallies
+  before_validation :prepare_cached_tallies
 
   after_commit :reset_parent_cache, on: :update
 
   def loaded_options
-    options.map.with_index { |title, key| Option.new(self, key.to_s, title, show_totals_now? ? cached_tallies[key] : nil) }
+    options.map.with_index { |title, key| Option.new(self, key.to_s, title, show_totals_now? ? (cached_tallies[key] || 0) : nil) }
   end
 
   def possibly_stale?