supersize supersize - 1 year ago 61
HTML Question

How to add inline styles to description of Rails link_to

I'm fairly new to Rails development, and would like to know how I can add inline styles to a

link_to
method like so:

= link_to "<b>menu<b> link", args, class: 'button'


I would like to make the word
menu
bold. How can achieve this?

Answer Source

Just call .html_safe on the name string:

= link_to "<b>menu<b> link".html_safe, args, class: 'button'

This allows the tags to be rendered as HTML instead of being escaped.