Skip to content

Commit 8363c53

Browse files
committed
fix(image_helper): handle ActiveStorage::FileNotFoundError in profile_image_tag method
1 parent 8d593c4 commit 8363c53

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app/helpers/better_together/image_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ def profile_image_tag(entity, options = {}) # rubocop:todo Metrics/MethodLength,
131131
default_image = default_profile_image(entity, image_format)
132132
image_tag(image_url(default_image), **image_tag_attributes)
133133
end
134+
rescue ActiveStorage::FileNotFoundError
135+
# Use a default image based on the entity type
136+
default_image = default_profile_image(entity, image_format)
137+
image_tag(image_url(default_image), **image_tag_attributes)
134138
end
135139
# rubocop:enable Metrics/AbcSize
136140
# rubocop:enable Metrics/CyclomaticComplexity

0 commit comments

Comments
 (0)