Skip to content

Instantly share code, notes, and snippets.

@vvalgis
Created December 28, 2010 11:02
Show Gist options
  • Save vvalgis/757135 to your computer and use it in GitHub Desktop.
Save vvalgis/757135 to your computer and use it in GitHub Desktop.
Delete "original" files extension for paperclip
# placed in config/initializers/paperclip.rb
module Paperclip
module InstanceMethods #:nodoc:
def save_attached_files
exceptions = [:scan]
each_attachment do |name, attachment|
if self.changed.include?("#{name}_updated_at")
logger.info("[paperclip] Saving attachments.")
attachment.send(:save)
unless exceptions.include?(name.to_sym)
File.delete attachment.path(:original) if File.exists?(attachment.path(:original))
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment