Ruby on rails 使用image_path为图片设置打开自己的链接

 <%= link_to image_tag("test.png", :class => "pic"), image_path("test.png")%>

关于image_path: 为图片匹配公共地址

image_path("edit")                                         # => "/images/edit"
image_path("edit.png")                                     # => "/images/edit.png"
image_path("icons/edit.png")                               # => "/images/icons/edit.png"
image_path("/icons/edit.png")                              # => "/icons/edit.png"
image_path("http://www.example.com/img/edit.png")          # => "http://www.example.com/img/edit.png"
转载自:

http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_path

你可能感兴趣的:(Ruby,on,Rails)