Nick
Nick

Reputation: 3090

Including bootstrap glyphicon in Rails link

I'm trying to include a bootstrap glyphicon in a Rails link. I thought:

<%= link_to "<i class="glyphicon glyphicon-check"></i>&nbsp; Sign up".html_safe, signup_path, :class => "button" %>

But apparently the way I include the glyphicon is incorrect as this on the server produces the error:

unexpected tIDENTIFIER, expecting ')' ...=( link_to "<i class="glyphicon glyphicon-check"></i>" + ....

When I remove the part the link works. How can I include the glyphicon in the link/button?

Upvotes: 1

Views: 941

Answers (3)

Milind
Milind

Reputation: 5112

try this...for example with link_to.my answer here

<%= link_to (‘<i class=“fa fa-thumbs-up fa-lg”> </i>’).html_safe, vote_path(@image), :method=> :delete, :remote=> true%>

Upvotes: 0

apneadiving
apneadiving

Reputation: 115511

I'd do :

<%= link_to signup_path, class: "button" do %>
  <i class="glyphicon glyphicon-check"></i>&nbsp; Sign up
<% end %>

I feel like its clearer.

Upvotes: 2

Nick
Nick

Reputation: 3090

Solution:

<%= link_to "<i class='glyphicon glyphicon-check'></i>&nbsp; Sign up".html_safe, signup_path, :class => "button" %>

So to use 'glyphicon glyphicon-check' instead of "glyphicon glyphicon-check".

Upvotes: 0

Related Questions