Jean
Jean

Reputation: 5411

html field for a blog content

I'm making my own blog with ruby on rails. But when I create a field for the content in the form, I can only show plain text. How can I show an html text from my field content.

Thanks

Upvotes: 0

Views: 658

Answers (1)

Björn Nilsson
Björn Nilsson

Reputation: 3773

In controller:
@some_variable = "<p>Hi there</p>"

In the view:
<%= @some_variable.html_safe %>

html_safe tells rails that your string is ok to display without escaping it first.

Upvotes: 1

Related Questions