Have you ever wanted to add an icon of some sort to a link, but couldn’t figure out how to add that <span><i class='glyphicon glyphicon-star'></i></span>
in there?
The solution is to use the link_to
helper as a block!
The formal syntax, as seen in the link_to
documentation, is:
link_to(options = {}, html_options = {}) do
# name
end
And translated into a more concrete example in an ERB template, it looks like:
<%= link_to your_path, class: 'your-class' do %>
<span><i class='glyphicon glyphicon-star'></i></span>
<% end %>
Thanks to this Stack Overflow answer for inspiring this post!