我想要一个包含文字和图片的链接。 在rails 3之前,互联网告诉我你必须这样做:
<%= link_to "my text"+image_tag("image.jpg"), {:controller=>:billets}, :class => 'link_to_blog'%>
然而,在rails 3中,我在我的网页中显示了图像的代码而不是图像。现在看来,它逃脱了html代码。
如何在rails 3中使用text和image进行link_to?
答案 0 :(得分:12)
<%= link_to ("my text"+image_tag("image.jpg")).html_safe, {:controller=>:billets}, :class => 'link_to_blog'%>
或者
<%= link_to {:controller => :billets}, :class => 'link_to_blog' do %>
My text
<%= image_tag "image.jpg" %>
<% end %>