method
to_plain_text
v8.0.0 -
Show latest stable
- Class:
ActionText::RichText
to_plain_text()public
Returns a plain-text version of the markup contained by the `body` attribute, with tags removed but HTML entities encoded.
message = Message.create!(content: "<h1>Funny times!</h1>") message.content.to_plain_text # => "Funny times!"
NOTE: that the returned string is not HTML safe and should not be rendered in browsers.
message = Message.create!(content: "<script>alert()</script>") message.content.to_plain_text # => "<script>alert()</script>"