From c35f09660a49f98e33bb3383d235736d7260dd40 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Wed, 19 Feb 2025 14:18:14 +0800 Subject: [PATCH] fix: handle nil safely for latest arts image - Update image tag to safely access the first latest art - Use safe navigation operator to prevent potential nil errors This change ensures that if there are no latest arts or if the image is not attached, the application will not raise an error. It improves the robustness of the view by handling edge cases. --- app/views/home/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 048de0c..22b1e5c 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -3,7 +3,7 @@
<% if @latest_arts.first&.image&.attached? %>
- <%= image_tag @latest_arts.first.webp_image.processed, class: "w-full h-full object-cover" %> + <%= image_tag @latest_arts&.first&.webp_image&.processed, class: "w-full h-full object-cover" %>
<% end %>