Reputation: 4406
I would like to return html content via jbuilder:
json.array!(@articles) do |article|
json.extract! article, :id, :title, :html_content
end
But it's returns escaped html:
{
"id": 2,
"title": "",
"html_content": "\u003cp\u003e\u003cimg alt=\"\" src=\"#\" /\u003e\u003c/p\u003e\r\n"
}
How can it return unescaped html?
Upvotes: 6
Views: 1299
Reputation: 2073
I believe the answer is to not retrieve the value via extract!
I think this should do the trick.
json.array!(@articles) do |article|
json.extract! article, :id, :title
json.html_content article.html_content
end
Upvotes: 0