Brandon4
(Brandon)
November 27, 2006, 11:05am
1
I'm trying to link to action using an image. This is what I'm working
with:
<img src="<%= product.image_url %>" />
<%= button_to ('Details', :action => 'details', :id => product ) %>
Is there a good way to make the *image* the clickable item? Any
insights into button_to, and link_to that you want to share are
appreciated.
<%= link_to image_tag(product.image_url), :action => 'details', :id =>
product %>
Brandon4
(Brandon)
November 27, 2006, 8:48pm
3
Thanks a lot!
Is that basically a nested method?
This is the same, but more readable. You pass the image as first parameter to the link_to method. The one posted before was simply omitting parenthesis:
<%= link_to(image_tag(product.image_url), :action => ‘details’, :id =>
product) %>
Brandon4
(Brandon)
November 28, 2006, 3:12am
5
which is better without parenthesis because it more legible, right?
Rodrigo Alvarez Fernández wrote: