fix: handle nil safely for latest arts image
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
Docker / docker (push) Has been cancelled

- 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.
This commit is contained in:
songtianlun 2025-02-19 14:18:14 +08:00
parent 789e9f8d23
commit c35f09660a

View File

@ -3,7 +3,7 @@
<section class="h-screen-90 relative overflow-hidden">
<% if @latest_arts.first&.image&.attached? %>
<div class="absolute inset-0">
<%= 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" %>
<div class="absolute inset-0 bg-gradient-to-r from-base-100/90 to-base-100/50"></div>
</div>
<% end %>