I want to use a bootstrap glyphicon as a link in my rails app. To do this without a glyphicon I would use the link_to method: <%= link_to "up", like_post_path(post), method: :put %>
I basically want the "up" to be a glyphicon instead. But I can not figure out how to add a link and still preserve the glyphicon as is. Here is all the code in my erb view relevant to my desired button:
<a href="" class="btn btn-success" aria-label="vote up" type="button">
<span class="glyphicon glyphicon-plus"></span>
</a>
I want to make this button link to my like_post_path(post). I've tried making the span into a button with the glyphicon classes, and a link_to method in the middle..didn't work. I've tried making the a href="<% many different erb attempts %> and no luck with that either. Can anyone tell me the proper way to do this?
Simply use
content_tag
:You can also use it with
link_to
:Or you can write the HTML code directly, and use the
raw
helper to avoid the ERB escape.