def attach(*attachables)
      if record.persisted? && !record.changed?
        record.update(name => blobs + attachables.flatten)
      else
        record.public_send("#{name}=", blobs + attachables.flatten)
      end
    end
def attach(*attachables)
      if record.persisted? && !record.changed?
        record.update(name => blobs + attachables.flatten)
      else
        record.public_send("#{name}=", blobs + attachables.flatten)
      end
    end
Attaches one or more +attachables+ to the record.

 If the record is persisted and unchanged, the attachments are saved to
 the database immediately. Otherwise, they'll be saved to the DB when the
 record is next saved.

   document.images.attach(params[:images]) # Array of ActionDispatch::Http::UploadedFile objects
   document.images.attach(params[:signed_blob_id]) # Signed reference to blob from direct upload
   document.images.attach(io: File.open("/path/to/racecar.jpg"), filename: "racecar.jpg", content_type: "image/jpg")
   document.images.attach([ first_blob, second_blob ])