Created
December 28, 2010 11:02
-
-
Save vvalgis/757135 to your computer and use it in GitHub Desktop.
Delete "original" files extension for paperclip
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
# 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