aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2018-12-20 20:15:45 -0500
committerGitHub <noreply@github.com>2018-12-20 20:15:45 -0500
commit086cc2b68e62a68fb378f4d039cfb55b3fdcb7de (patch)
tree23271fcda3002695ee33d8b5e09954081ac97cd8 /app/models
parent097235bc41e7e4707369991eb79284b0f9ddd71c (diff)
parentecfada837a464df1ffa50789d4e555ffde6108f4 (diff)
downloadrails-086cc2b68e62a68fb378f4d039cfb55b3fdcb7de.tar.gz
rails-086cc2b68e62a68fb378f4d039cfb55b3fdcb7de.tar.bz2
rails-086cc2b68e62a68fb378f4d039cfb55b3fdcb7de.zip
Merge pull request #48 from lsylvester/use-plain-text-for-presence
use plain test to determine present/blank/empty
Diffstat (limited to 'app/models')
-rw-r--r--app/models/action_text/rich_text.rb8
1 files changed, 6 insertions, 2 deletions
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