Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing an image and text inside an link_to helper (Rails)?

I added an image inside a link_to helper:

 <% 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" %>

How can I do it so that I can place some text within the link and right after the image (like the like button in YouTube)?

like image 728
alexchenco Avatar asked Mar 07 '12 13:03

alexchenco


1 Answers

You can pass a block to the link_to helper

<%= link_to vote_up_path(@votable, :votable_type => "Post"), :remote => true, :class => "vote-up default button" do %>
  <%= image_tag("like.png", :alt => "like", :class => "like") %>
  <span>Like</span>
<% end %>
like image 161
Carlos Ramirez III Avatar answered Oct 13 '22 03:10

Carlos Ramirez III