supersize supersize - 5 months ago 10
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

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.

Comments