instance method
to_plain_text
Ruby on Rails 8.1.2
Since v6.0.6Signature
to_plain_text()
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>"
Source
# File actiontext/app/models/action_text/rich_text.rb, line 72
def to_plain_text
body&.to_plain_text.to_s
end
Defined in actiontext/app/models/action_text/rich_text.rb line 72
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionText::RichText