diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2018-05-28 17:43:21 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-05-28 17:43:21 +0200 |
commit | e63acf4513dec5f2dc08293d8141971850fe4853 (patch) | |
tree | 3471a93c31863ce70d36983d7257096876349f7f /lib | |
parent | 94a95db2f5cf48b63d1bd08d849790156572a1f5 (diff) | |
download | rails-e63acf4513dec5f2dc08293d8141971850fe4853.tar.gz rails-e63acf4513dec5f2dc08293d8141971850fe4853.tar.bz2 rails-e63acf4513dec5f2dc08293d8141971850fe4853.zip |
Auto-save changes to rich text model
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_text/attribute.rb | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/action_text/attribute.rb b/lib/action_text/attribute.rb index 3b855901e8..81bd226646 100644 --- a/lib/action_text/attribute.rb +++ b/lib/action_text/attribute.rb @@ -17,19 +17,9 @@ module ActionText has_one :"rich_text_#{name}", -> { where(name: name) }, class_name: "ActionText::RichText", as: :record, inverse_of: :record, dependent: false scope :"with_rich_text_#{name}", -> { includes("rich_text_#{name}") } - end - - # def has_rich_text(attribute_name) - # serialize(attribute_name, ActionText::Content) - # - # has_many_attached "#{attribute_name}_attachments" - # - # after_save do - # blobs = public_send(attribute_name).attachments.map(&:attachable) - # public_send("#{attribute_name}_attachments_blobs=", blobs) - # end - # end + after_save { public_send(name).save if public_send(name).changed? } + end end end end |