GVS
GVS

Reputation: 229

How to add glyphicon to link_to

I am trying to replace the word "like" with a heart icon.

Basically, I am trying to add <i class="glyphicon glyphicon-heart"></i> to the following:

<%= link_to 'Like', like_post_path(post), method: :post %>

Upvotes: 0

Views: 72

Answers (2)

Pradeep Sapkota
Pradeep Sapkota

Reputation: 2072

This is for you

<%= link_to '<i class="glyphicon glyphicon-heart"></i> Like'.html_safe, like_post_path(post), method: :post %>

Upvotes: 0

Ursus
Ursus

Reputation: 30056

Try something like

<%= link_to like_post_path(post), method: :post do %>
  <i class="glyphicon glyphicon-heart"></i>
<% end %>

Upvotes: 1

Related Questions