Reputation: 2660
New to RoR, so please don't kill me ;)
Was wondering why does not Rails 3 recognize HTML tags retrieved from database?
For example,
Name Content
Title <b>Great</b> Show Edit Destroy
I wanted to have Content to be bold and put < b > tag around it, when it retrieves from a database it looks like a plain English.
Any thoughts?
Thank you in advance.
Upvotes: 0
Views: 335
Reputation: 984
Even though it is unsafe to deliberately output HTML from the DB, you should call raw
on the content you're trying to print.
<%= raw @object.my_content %>
Upvotes: 1
Reputation: 10423
If I got this right, you need to do this:
<%= myrecord.content.html_safe %>
to get "real" html and not just escaped html code.
Upvotes: 2