method

to_plain_text

Importance_1
v8.0.0 - Show latest stable - 0 notes - Class: 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>"
Show source
Register or log in to add new notes.