Estos son los métodos de clip que se pueden utilizar para eliminar los archivos adjuntos:
module Paperclip
class Attachment
# Clears out the attachment. Has the same effect as previously assigning
# nil to the attachment. Does NOT save. If you wish to clear AND save,
# use #destroy.
def clear
queue_existing_for_delete
@errors = {}
end
# Destroys the attachment. Has the same effect as previously assigning
# nil to the attachment *and saving*. This is permanent. If you wish to
# wipe out the existing attachment but not save, use #clear.
def destroy
clear
save
end
Como puede ver, destruyen sólo elimina el archivo adjunto si no ocurre ningún error. Lo he probado con mi propia configuración contra S3, así que sé que destruir funciona.
¿Es posible que el problema en su caso sea que tiene validaciones que cancelan el guardado? Es decir validates_attachment_presence o algo similar?
Creo que una forma de averiguarlo sería probar @ user.logo.destroy y luego verificar el contenido de @ user.errors para ver si informa algún mensaje de error.
Hice como usted enumeró aquí, puede por favor ver mi pregunta aquí: http://stackoverflow.com/questions/14144454/how-to-hook-for-destroy-of-a-model-that-belongs- a-otro-modelo – simo