For example if my field contains
description: "<p>Some Text </p>"
and I display it in my html.erb file as item.description
How can I remove this p tags?
<div class="preview__text">
<%= sanitize(item.description) %>
</div>
or
<div class="preview__text">
<%= item.description.html_safe %>
</div>
CodePudding user response:
You can use strip_tags method in ActionView: : Helpers : : SanitizeHelper :
https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags
CodePudding user response:
You can use .html_safe
<%= item.description.html_safe %>
Or sanitize
<%= sanitize(item.description) %>