Skip to content

Instantly share code, notes, and snippets.

@josevalim
Created February 23, 2011 13:09
Show Gist options
  • Save josevalim/840409 to your computer and use it in GitHub Desktop.
Save josevalim/840409 to your computer and use it in GitHub Desktop.
# 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