I'm trying to link an image to an external URL from my index.html.erb page but it's not working. Any suggestions?
<%= link_to image_tag "facebook.png", "http://www.facebook.com" %>
I am also t开发者_Python百科rying to link a 'send-to-friend' email image - so when a user clicks it, their email client will open automatically with a pre-written title and message ready to send. Can anyone help with this one?
It may be thinking the url is a second parameter to the image_tag
method rather than to the link_to
method, so wrap that up the image_tag
parameters in parentheses to avoid confusion:
<%= link_to image_tag("facebook.png"), "http://www.facebook.com" %>
精彩评论