From ecfada837a464df1ffa50789d4e555ffde6108f4 Mon Sep 17 00:00:00 2001 From: Lachlan Sylvester Date: Fri, 21 Dec 2018 12:04:30 +1100 Subject: use plain test to determine present/blank/empty as the html version will always contain content --- app/models/action_text/rich_text.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/action_text/rich_text.rb b/app/models/action_text/rich_text.rb index 1f8ac0e7f7..d44046e863 100644 --- a/app/models/action_text/rich_text.rb +++ b/app/models/action_text/rich_text.rb @@ -8,8 +8,12 @@ class ActionText::RichText < ActiveRecord::Base self.table_name = "action_text_rich_texts" serialize :body, ActionText::Content - delegate :to_s, :to_plain_text, :nil?, to: :body - delegate :blank?, :empty?, :present?, to: :to_s + delegate :to_s, :nil?, to: :body + delegate :blank?, :empty?, :present?, to: :to_plain_text + + def to_plain_text + body&.to_plain_text.to_s + end belongs_to :record, polymorphic: true, touch: true has_many_attached :embeds -- cgit v1.2.3