:neil_middleton

Ruby on Rails, Web Application Development and bollocks extraordinaire 
« Back to blog

Rails 3 and escaped HTML

Something work remembering that keeps catching me out is surround Rails 3 and it's assumption that everything is NOT html safe (a change of opinion from Rails 2).

Now, all strings are html escaped by default:

To unescape the HTML (i.e you already know that the string is OK to render out), you need to mark it as html_safe:

Simple.

Comments (3)

May 10, 2010
Or
<%=raw some_string %>
Jul 19, 2010
Micah Alcorn said...
Thank you so much for pointing this out. I don't know why I couldn't find this.
Jul 19, 2010
Micah Alcorn said...
Thank you so much for pointing this out. I don't know why I couldn't find this.

Leave a comment...