diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-12 10:58:23 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-12 10:58:23 -0700 |
commit | 3431c0b3eeaf284901bd9aa4265c578207d4c820 (patch) | |
tree | bad6de7844972fa8e39666e87f875b03676dd6a3 /app | |
parent | 0fd8ba6ffff07a4556ec47840ef8c9dbd10e5e8b (diff) | |
download | rails-3431c0b3eeaf284901bd9aa4265c578207d4c820.tar.gz rails-3431c0b3eeaf284901bd9aa4265c578207d4c820.tar.bz2 rails-3431c0b3eeaf284901bd9aa4265c578207d4c820.zip |
Ensure blank rich text records aren't saved or required
Diffstat (limited to 'app')
-rw-r--r-- | app/models/action_text/rich_text.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/action_text/rich_text.rb b/app/models/action_text/rich_text.rb index 7c0fdf240d..445b444867 100644 --- a/app/models/action_text/rich_text.rb +++ b/app/models/action_text/rich_text.rb @@ -6,6 +6,8 @@ class ActionText::RichText < ActiveRecord::Base belongs_to :record, polymorphic: true, touch: true has_many_attached :embeds + validate { errors.add(:body, "is missing") if body.blank? } + before_save do self.embeds = body.attachments.map(&:attachable) end |