Created
February 23, 2011 13:09
-
-
Save josevalim/840409 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Assuming you mounted it as attachment... | |
def update_attributes(attributes) | |
@previous_attachment = self.attachment | |
super | |
end | |
after_update do | |
if @previous_attachment && @previous_attachment.file != attachment.try(:file) | |
@previous_attachment.remove! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment