यह है कि संलग्नक दूर करने के लिए इस्तेमाल किया जा सकता पेपरक्लिप से तरीके हैं:
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
तो आप देखते हैं, को नष्ट कोई त्रुटि होती है तो केवल लगाव को हटा। मैंने एस 3 के खिलाफ अपने स्वयं के सेटअप के साथ कोशिश की है, इसलिए मुझे पता है कि काम नष्ट कर देता है।
क्या आपके मामले में समस्या संभव हो सकती है कि आपके पास कोई सत्यापन है जो सहेजने को रद्द कर देता है? I.e validates_attachment_presence या कुछ समान है?
मुझे लगता है कि पता लगाने का एक तरीका @ user.logo.destroy को आजमाया जाएगा और फिर यह देखने के लिए @ user.errors की सामग्री जांचें कि यह किसी भी त्रुटि संदेश की रिपोर्ट करता है या नहीं।
जैसा आपने यहां सूचीबद्ध किया है, क्या आप यहां मेरा प्रश्न देख सकते हैं: http://stackoverflow.com/questions/14144454/how-to-hook-for-destroy-of-a-model-that-belongs- टू-एक और मॉडल – simo