Thoughts, information and reflections about technology

A quick way to have a link_to show as a button instead of a text link

link_to can be modified to show a button instead of a text link. The trick is to enclose the link/button text in a button tag and add .html_safe .

<%= link_to ““.html_safe, ‘http://blog.chrismendlatech.com’, target:’_blank’, class: ‘button’%>

<%= link_to "< button>My Blog< /button>".html_safe, 'http://blog.chrismendlatech.com', target:'_blank', class: 'button'%>

Since there is no user input here, html_safe should be safe to use. However, you need to decide for yourself on a case by case basis.

Similar Posts:

No tags for this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact me
Archives
Categories
Recent Comments