Created
March 2, 2016 08:24
-
-
Save 1990prashant/3ccf1c1c18ec7996741b to your computer and use it in GitHub Desktop.
To delete paperclip attachment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_image | |
@user.image.clear #This is optional you can skip it | |
@user.image.destroy #This line delete image from paperclip | |
# Now you need to update image url because destroy is not remove url so you need to update image field | |
@user.update_attributes(image: nil) | |
end | |
#Note: You can directaly update your image field but it doesn't delete image from storage. | |
#Note1: Controller name may be changed according to your requirement. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment