aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-12 15:51:06 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-12 15:51:06 -0700
commit531d7dd584267e81ba57d4de7f0fe21b18a83cbb (patch)
tree1e65cf6bda11cc03bdcebdc9183a84abb5aef58c /lib
parent3431c0b3eeaf284901bd9aa4265c578207d4c820 (diff)
downloadrails-531d7dd584267e81ba57d4de7f0fe21b18a83cbb.tar.gz
rails-531d7dd584267e81ba57d4de7f0fe21b18a83cbb.tar.bz2
rails-531d7dd584267e81ba57d4de7f0fe21b18a83cbb.zip
Never mind on allowing blank
More hassle than its worth. Just account for the fact that rich text can be blank instead, but continue to create the record.
Diffstat (limited to 'lib')
-rw-r--r--lib/action_text/attribute.rb13
1 files changed, 1 insertions, 12 deletions
diff --git a/lib/action_text/attribute.rb b/lib/action_text/attribute.rb
index 67ade42eb1..8426726a38 100644
--- a/lib/action_text/attribute.rb
+++ b/lib/action_text/attribute.rb
@@ -37,19 +37,8 @@ module ActionText
scope :"with_rich_text_#{name}", -> { includes("rich_text_#{name}") }
scope :"with_rich_text_#{name}_and_embeds", -> { includes("rich_text_#{name}": { embeds_attachments: :blob }) }
- before_save do
- # If there's no body set, we need to reset the rich text record such that it is not autosaved.
- public_send("#{name}=", nil) if public_send(name).body.blank?
- end
-
after_save do
- rich_text = public_send(name)
-
- if rich_text.changed? && rich_text.body.present?
- rich_text.save
- elsif rich_text.persisted? && rich_text.body.blank?
- rich_text.destroy
- end
+ public_send(name).save if public_send(name).changed?
end
end
end