I am creating a method on my model that I can use to return the URL to the correct logo, photo or a fallback image. My code is:
def image
if photo1.attached?
{ url: photo1.url, alt: "Photo of #{full_name}" }
elsif photos.any?
photo = photos.first
url = photo.url(:large_square)
{ url: url, alt: "Photo of #{full_name}" }
else
{ url: url_for(asset_path "placeholder.svg"), alt: "Placeholder for #{full_name}" }
end
end
But it’s erroring with url_for
and asset_path
and i’m unsure how to resolve it?