]> cat aescling's git repositories - mastodon.git/commitdiff
Fix regression in `tootctl search deploy` caused by unloaded attribute (#18514)
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 26 May 2022 16:05:47 +0000 (18:05 +0200)
committersingle-right-quote <11325618-aescling@users.noreply.gitlab.com>
Fri, 27 May 2022 03:54:58 +0000 (23:54 -0400)
app/models/poll.rb

index ba08309a15c9bddd804552db65f7bcd9f0a8d4a9..1a326e452c6faeb970288725ab3d808f4df2223e 100644 (file)
@@ -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?