aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_text/attribute.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/active_text/attribute.rb')
-rw-r--r--lib/active_text/attribute.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/active_text/attribute.rb b/lib/active_text/attribute.rb
index 577adde83a..9d872a87a1 100644
--- a/lib/active_text/attribute.rb
+++ b/lib/active_text/attribute.rb
@@ -5,6 +5,13 @@ module ActiveText
class_methods do
def active_text_attribute(attribute_name)
serialize(attribute_name, ActiveText::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
end
end