class ActiveStorage::Attached::One

def detach

Deletes the attachment without purging it, leaving its blob in place.
def detach
  if attached?
    attachment.destroy
    write_attachment nil
  end
end