Reputation: 749
I want to turn my image into a link. But how? I read different answers but nothing worked.
<%= link_to image_tag(article.images.first.image.url, :alt => article.title) unless
article.images.first.nil? %>
I used this link to refer to the article by the title.
<%= link_to(article) do %><h2><%= article.title %></h2><% end %>
This works! the path. But i want the same path "article" with the image.
Upvotes: 0
Views: 123
Reputation: 11868
This should work:
<%= link_to image_tag(article.images.first.image.url, :alt => article.title) unless
article.images.first.nil?, article %>
Upvotes: 0