From 22625c493a7c0820ef41a5340ebfb2f16506207c Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 6 Feb 2025 19:12:18 -0600 Subject: [PATCH] Use `Time.current`, make this resilient to null values --- app/views/bubbles/_pop_toggle.html.erb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/views/bubbles/_pop_toggle.html.erb b/app/views/bubbles/_pop_toggle.html.erb index 8f28a172a..46ab09cfd 100644 --- a/app/views/bubbles/_pop_toggle.html.erb +++ b/app/views/bubbles/_pop_toggle.html.erb @@ -1,8 +1,11 @@ -
<% if bubble.popped? %> <% event = bubble.events.where(action: "popped").last %> - Popped by <%= event.creator.name %> on <%= event.created_at.to_date.strftime('%B %-d') %>. + <% if event %> + Popped by <%= event.creator.name %> on <%= event.created_at.to_date.strftime('%B %-d') %>. + <% else %> + Popped + <% end %> <%= button_to bucket_bubble_pop_path(bubble.bucket, bubble), method: :delete, class: "btn btn--plain borderless fill-transparent" do %> Un-pop <% end %> @@ -12,8 +15,10 @@ <%= image_tag "pop.svg", aria: { hidden: true }, size: 24, class: "colorize--white" %> Pop <% end %> - - (Pops automatically in <%= distance_of_time_in_words(Date.today, event.created_at + 30.days) %>.) - + <% if event %> + + (Pops automatically in <%= distance_of_time_in_words(Time.current, event.created_at + 30.days) %>.) + + <% end %> <% end %>