if first_image h.content_tag :img, first_image.url(:cover) else h.content_tag :img, ‘fallback/default_cover.png’ end end end ! #app/views/products/show.html.erb ! <%= cover_image(@product) %>
first_image = object.images.try(:first) if first_image h.image_tag first_image.image_url(:cover) else h.image_tag ‘fallback/cover_image.png’ end end end