Create ASt::Attachment records for ASt::Blobs in content

This commit is contained in:
Javan Makhmali 2018-02-14 10:33:30 -05:00
parent 6408111e71
commit 9ded0f3c42
1 changed files with 7 additions and 0 deletions

View File

@ -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