Using the raw and html_safe methods with Rails 3.0.10 and I am still unable to unescape the html and get it to display as Content instead of <strong>Content</strong>
.
@object.property.html_safe
gives me <strong>Some content</strong>
<%= raw(@object.property) %>
also gives me <strong>Some content</strong>
I have seen these posts and tried to implement their fixes:
- raw vs. html_safe vs. h to unescape html
- Disable HTML escaping in erb templates
- How to make html code in erb tag not escaped
I have also watched the Ryan Bates Railscasts episode about xss protection: http://railscasts.com/episodes/204-xss-protection-in-rails-3?view=comments
I created a helper method based on his example called safe where I made sure the string content had the html_safe method applied:
def safe(content)
"#{content}".html_safe
end
Then I called it on my model: safe(@object.property)
Still the content is not displaying as expected.
I have also tried using the sanitize method, but to no avail.
What could be causing this?