How to add glyphicons to rails link_to helper - Bootstrap 3

Viewed 39052

I've been looking everywhere for a good explanation of how to add glyphicons to rails link_to and button_to helpers, but I've found very little. What I've gathered so far has led me to this:

<li>
  <%= link_to deals_path, class: "btn btn-default" do %>
    <%= content_tag(:i, "Dasboard",:class=>' glyphicon, glyphicon-th-large') -%>
  <% end %>
</li>

This doesn't work though and I think the one example I found was from Bootstrap 2. Can anyone point me to a good resource on this, or provide a quick example? Thanks in advance!

8 Answers

There is faster and easier way to apply (fontawasome) icons without additional gem installations.

You may follow this pattern:

          <%= link_to root_path, class: "nav-link" do %>
            <i class="fas fa-pencil-alt"></i>
          <% end %>

Of course, you must first create a kit FREE account from the FONTAWASOME and it must be set in your application.html.erb's head to use the icons. Follow the instructions given here to create an account in Fontawasome (if you don't have one yet).

If you need an example, you can check out my repo in GitHub

Related