From 3b5d0ac000249f1a391328cac011f14e6bd6db94 Mon Sep 17 00:00:00 2001 From: Robyn-Dale Samuda Date: Mon, 15 Mar 2021 20:49:54 -0500 Subject: [PATCH] Safe nav operator to render announcement description on index page Prior to introducing the presence validation on Announcement.description, several announcements were created in production without a description. This broke nil description references and this approach returns nil as a fallback and facilitates type casting --- app/views/announcements/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/announcements/index.html.erb b/app/views/announcements/index.html.erb index 46cab046d..86473ed1f 100644 --- a/app/views/announcements/index.html.erb +++ b/app/views/announcements/index.html.erb @@ -6,8 +6,8 @@
  • <%= announcement.name %>

    - <%= announcement.description.truncate(100) %> - <%= link_to("More [*]", announcement_path(announcement)) if announcement.description.length > 100 %> + <%= announcement.description&.truncate(100) %> + <%= link_to("More [*]", announcement_path(announcement)) if announcement.description&.length.to_i > 100 %>

    <% if policy(announcement).change? %>