Reputation: 6858
I want a picture of my product to link to the product show page. I've tried:
<%= link_to product.photos.first.image.url(:small), product%>
which produces
<a href="/products/64">/system/photos/images/000/000/023/small/4462867927_3741423c39_o.jpg?1395899030</a>
I've also tried
<a href="<%= products_path(product) %>"> <%= image_tag product.photos.first.image.url(:small) %> </a>
which produces:
<a href="/products.64"> <img alt="4462867927 3741423c39 o" src="/system/photos/images/000/000/023/small/4462867927_3741423c39_o.jpg?1395899030"> </a>
And that's not right either. Whats the best way to do this in Rails?
Upvotes: 0
Views: 115
Reputation: 4703
<%= link_to image_tag(product.photos.first.image.url(:small)), product %>
Upvotes: 1