def unpersisted_attachments(method)
      as_relation = @object.send(method)
      if as_relation.is_a?(ActiveStorage::Attached::One) && as_relation.attachment.present? &&
         !@object.persisted?
        [as_relation.attachment]
      elsif as_relation.is_a?(ActiveStorage::Attached::Many)
        as_relation.reject(&:persisted?)
      else
        []
      end
    end
def unpersisted_attachments(method)
      as_relation = @object.send(method)
      if as_relation.is_a?(ActiveStorage::Attached::One) && as_relation.attachment.present? &&
         !@object.persisted?
        [as_relation.attachment]
      elsif as_relation.is_a?(ActiveStorage::Attached::Many)
        as_relation.reject(&:persisted?)
      else
        []
      end
    end
Returns an array of all unpersisted file attachments (e.g. left over after a failed
 validation)

 @author Ian Grant
 @param [Symbol] method The attribute on the target model to attach the files to.
 @return [Array] An array of unpersisted file attachments.