Follow Along as I Stumble on the Path to Learning RoR

Allowing HTML Tags in Form Fields

I wanted to allow my users to be able to include html tags in things they posted.  Originally, I was thinking that this was done as an option to the form field, but it actually is in the view where you display the user content.

In my case, I have this in the form:

<%= f.text_area :content %>

and where you want to display it, just add “.html_safe”, for example:

<%= article.content.html_safe %>

Advertisements

Comments are closed.