instance method to_trix_html

Ruby on Rails 8.1.2

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

to_trix_html()

Returns the body attribute in a format that makes it editable in the Trix editor. Previews of attachments are rendered inline.

content = "<h1>Funny Times!</h1><figure data-trix-attachment='{\"sgid\":\"..."\}'></figure>"
message = Message.create!(content: content)
message.content.to_trix_html # =>
# <div class="trix-content">
#   <h1>Funny times!</h1>
#   <figure data-trix-attachment='{\"sgid\":\"..."\}'>
#      <img src="http://example.org/rails/active_storage/.../funny.jpg">
#   </figure>
# </div>
Source
# File actiontext/app/models/action_text/rich_text.rb, line 88
    def to_trix_html
      body&.to_trix_html
    end

Defined in actiontext/app/models/action_text/rich_text.rb line 88 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionText::RichText

Type at least 2 characters to search.

↑↓ navigate · open · esc close