我在link_to帮助器中添加了一个图像:
<% like = image_tag("like.png",:alt => "like",:class => "like") %> <%= link_to like,vote_up_path(@votable,:votable_type => "Post"),:remote => true,:class => "vote-up default button" %>
我怎么能这样做,以便我可以在链接中和图像后面放置一些文本(如YouTube中的类似按钮)?
解决方法
您可以将块传递给link_to帮助程序
<%= link_to vote_up_path(@votable,:class => "vote-up default button" do %> <%= image_tag("like.png",:class => "like") %> <span>Like</span> <% end %>