class Content
Ruby on Rails 8.1.2
Since v6.0.6Action Text Content
The ActionText::Content class wraps an HTML fragment to add support for parsing, rendering and serialization. It can be used to extract links and attachments, convert the fragment to plain text, or serialize the fragment to the database.
The ActionText::RichText record serializes the body attribute as ActionText::Content.
class Message < ActiveRecord::Base has_rich_text :content end message = Message.create!(content: "<h1>Funny times!</h1>") body = message.content.body # => #<ActionText::Content "<div class=\"trix-conte..."> body.to_s # => "<h1>Funny times!</h1>" body.to_plain_text # => "Funny times!"
Inherits from
Attributes
Methods (defined here)
- # ==
- # append_attachables
- # as_json
- # attachables
- # attachment_galleries
- # attachments
- # gallery_attachments
- # inspect
- # links
- # render_attachment_galleries
- # render_attachments
- # to_html
- # to_partial_path
- # to_plain_text
- # to_rendered_html_with_layout
- # to_s
- # to_trix_html
- self. fragment_by_canonicalizing_content
- self. new
Private methods
(4)
Implementation detail — not part of the public API.
Methods (inherited)
From Object (17)
- # acts_like?
- # blank?
- # deep_dup
- # duplicable?
- # html_safe?
- # in?
- # instance_values
- # instance_variable_names
- # presence
- # presence_in
- # present?
- # to_param
- # to_query
- # try
- # try!
- # with
- # with_options
From ActiveSupport::NumericWithFormat (2)
- # to_formatted_s
- # to_fs