class
ActionText::RichText
v8.0.0 -
Show latest stable
- Superclass: ActiveRecord::Base
The RichText record holds the content produced by the Trix editor in a serialized `body` attribute. It also holds all the references to the embedded files, which are stored using Active Storage. This record is then associated with the Active Record model the application desires to have rich text content using the `has_rich_text` class method.
class Message < ActiveRecord::Base has_rich_text :content end message = Message.create!(content: "<h1>Funny times!</h1>") message.content #=> #<ActionText::RichText.... message.content.to_s # => "<h1>Funny times!</h1>" message.content.to_plain_text # => "Funny times!" message = Message.create!(content: "<div onclick='action()'>safe<script>unsafe</script></div>") message.content #=> #<ActionText::RichText.... message.content.to_s # => "<div>safeunsafe</div>" message.content.to_plain_text # => "safeunsafe"
Files
- actiontext/app/models/action_text/rich_text.rb