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.
- Rails – Pop up window with no header, footer or navigation
- Creating pop ups in rails
- Let’s put the SHRED button right next to the SCAN button.
- Adding an Anchor Link to Headers in WordPress with Gutenberg
- Shading Cells in Ruby depending on the contents of the cell
- Going back two pages in Ruby on Rails
- Showing the file name before committing to an upload of a CSV file in Ruby on Rails
- Twitshot allows you to easily post images from your blog to Twitter