class ActionText::RichText
message.content.to_plain_text # => “safeunsafe”
message.content.to_s # => “<div>safeunsafe</div>”
message.content #=> #<ActionText::RichText.…
message = Message.create!(content: “<div onclick=‘action()’>safe<script>unsafe</script></div>”)
message.content.to_plain_text # => “Funny times!”
message.content.to_s # => “<h1>Funny times!</h1>”
message.content #=> #<ActionText::RichText.…
message = Message.create!(content: “<h1>Funny times!</h1>”)
end
has_rich_text :content
class Message < ActiveRecord::Base
using the ‘has_rich_text` class method.
with the Active Record model the application desires to have rich text content
files, which are stored using Active Storage. This record is then associated
serialized `body` attribute. It also holds all the references to the embedded
The RichText record holds the content produced by the Trix editor in a
# Action Text RichText
def to_plain_text
message = Message.create!(content: "<script>alert()</script>")
browsers.
NOTE: that the returned string is not HTML safe and should not be rendered in
message.content.to_plain_text # => "Funny times!"
message = Message.create!(content: "
Funny times!
")with tags removed but HTML entities encoded.
Returns a plain-text version of the markup contained by the `body` attribute,
def to_plain_text body&.to_plain_text.to_s end
def to_trix_html
#
#
#