aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-12 10:58:23 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-12 10:58:23 -0700
commit3431c0b3eeaf284901bd9aa4265c578207d4c820 (patch)
treebad6de7844972fa8e39666e87f875b03676dd6a3 /app/models
parent0fd8ba6ffff07a4556ec47840ef8c9dbd10e5e8b (diff)
downloadrails-3431c0b3eeaf284901bd9aa4265c578207d4c820.tar.gz
rails-3431c0b3eeaf284901bd9aa4265c578207d4c820.tar.bz2
rails-3431c0b3eeaf284901bd9aa4265c578207d4c820.zip
Ensure blank rich text records aren't saved or required
Diffstat (limited to 'app/models')
-rw-r--r--app/models/action_text/rich_text.rb2
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