From 3431c0b3eeaf284901bd9aa4265c578207d4c820 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 12 Sep 2018 10:58:23 -0700 Subject: Ensure blank rich text records aren't saved or required --- app/models/action_text/rich_text.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/models') 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 -- cgit v1.2.3