Class: Domternal::RichText
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Domternal::RichText
- Defined in:
- app/models/domternal/rich_text.rb
Overview
Holds the HTML body + Active Storage embeds for a single has_rich_domternal attribute.
Body is stored as the same sanitized HTML the Domternal editor renders/re-parses
(Domternal's Editor/DomternalEditor accept HTML directly as content), so no
separate JSON<->HTML conversion step is needed on the Ruby side.
Instance Method Summary collapse
Instance Method Details
#to_plain_text ⇒ Object
23 24 25 |
# File 'app/models/domternal/rich_text.rb', line 23 def to_plain_text body.to_s.gsub(/<[^>]*>/, " ").gsub(/\s+/, " ").strip end |
#to_s ⇒ Object
19 20 21 |
# File 'app/models/domternal/rich_text.rb', line 19 def to_s body.to_s.html_safe # rubocop:disable Rails/OutputSafety -- sanitized in #sanitize_body before persistence end |