Tag Archives: html_safe?

Allow HTML String – Ruby on Rails

Just a quick post on how to prevent escaping for HTML within a string. Simply use html_safe?.

i.e. The following will show the bold tags as text:

<%= "GOOOOOOOGLE">

<b>GOOOOOOOGLE</b>

Whereas once we add html_safe the text will be displayed in bold:

<%= ("GOOOOOOOGLE").html_safe?>

GOOOOOOOGLE