diff options
author | Lachlan Sylvester <lachlan.sylvester@blake.com.au> | 2018-12-21 12:04:30 +1100 |
---|---|---|
committer | Lachlan Sylvester <lachlan.sylvester@blake.com.au> | 2018-12-21 12:04:30 +1100 |
commit | ecfada837a464df1ffa50789d4e555ffde6108f4 (patch) | |
tree | c0073013b39c77d2b1edd4d70ec0a81472ad4d9b /app/models | |
parent | 18974137be2c4027dfcf430668edd712e7ec011b (diff) | |
download | rails-ecfada837a464df1ffa50789d4e555ffde6108f4.tar.gz rails-ecfada837a464df1ffa50789d4e555ffde6108f4.tar.bz2 rails-ecfada837a464df1ffa50789d4e555ffde6108f4.zip |
use plain test to determine present/blank/empty as the html version will always contain content
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/action_text/rich_text.rb | 8 |
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 |