Today I Learned

hashrocket A Hashrocket project

Inserting HTML into your rails view

When inserting html into your rails view from a record, you might do it in one of two similar ways:

<%= @webpage.content.html_safe %>

<%= raw @webpage.content %>

This can also be accomplished by adding in another =

<%== @webpage.content %>

<%== %> is equivalent to raw, and raw calls html_safe on whatever it is passed.

h/t Matt Polito

See More #rails TILs
Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.