开发者

In rails 3 how do you have text and image in link_to?

开发者 https://www.devze.com 2023-03-27 17:57 出处:网络
I want a link with text and an image. Before rails 3 i开发者_JS百科nternet tells me that you must do :

I want a link with text and an image. Before rails 3 i开发者_JS百科nternet tells me that you must do :

<%= link_to "my text"+image_tag("image.jpg"), {:controller=>:billets}, :class => 'link_to_blog'%>

However in rails 3 i have the code of the image displayerd in my web page instead of the image. Seems now, it escape the html code.

How can i do a link_to with text and image in rails 3?


<%= link_to ("my text"+image_tag("image.jpg")).html_safe, {:controller=>:billets}, :class => 'link_to_blog'%>

Or

<%= link_to {:controller => :billets}, :class => 'link_to_blog' do %>
  My text
  <%= image_tag "image.jpg" %>
<% end %>
0

精彩评论

暂无评论...
验证码 换一张
取 消