如何将图像转换为Rails中的链接?
我只是想在图片上做一个简单的链接。
<a href="http://www.mysite.com"><img src="path/to/image.png"/></a> 你怎么用link_to rails标签来做到这一点?
 使用image_tag作为link_to的内容。 
 link_to image_tag("path/to/image.png"), "http://www.mysite.com/" 
我的解决scheme
 <%= link_to root_path do %> <%= image_tag "image.jpg", class: "some css class here" %> <% end %> 
 干一个 
 在你的application_helper.rb 
 def link_to_image(image_path, target_link,options={}) link_to(image_tag(image_path, :border => "0"), target_link, options) end 
然后从你的意见
 <%= link_to_image("path/to/image", some_url) %> 
 <%= link_to(image_tag("path/to/image.png"), root_path) %> 
 其中root_path是您的网站主页的路线。