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