I'm new to Stackoverflow and new to Rails and I'm trying to display a clickable image in Rails. What I want to do is display the image, make it clickable and when you click on the image you can use the image viewer to zoom in. This works:
<%= link_to "Show Images", "image_path" %>
where image_path is a direct URL. When you click on the "Show Images" link, you're able to zoom in on the image. Instead of showing the text "Show Images" I want to show the image. I've tried this:
<%= link_to image_tag "image_path", "image_path" %>
But its giving me errors. I even tried putting parenthesies around the fields but it doesn't work. What am I doing wrong here? Thanks,
-LRC-
The following should work.
<%= link_to image_path do %>
<%= image_tag image_path %>
<% end %>
If you put the parentheses like this, it should work:
<%= link_to image_tag("image_path"), "image_path" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With