2018-02-08 20:48:45 +00:00
|
|
|
module ActiveText
|
|
|
|
module Attribute
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class_methods do
|
|
|
|
def active_text_attribute(attribute_name)
|
|
|
|
serialize(attribute_name, ActiveText::Content)
|
2018-02-14 15:33:30 +00:00
|
|
|
|
|
|
|
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
|
2018-02-08 20:48:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|