lib/paperclip/storage/database.rb in paperclip_database-1.0.0 vs lib/paperclip/storage/database.rb in paperclip_database-1.0.1

- old
+ new

@@ -100,11 +100,15 @@ #FIXME: This should be fixed in ActiveRecord... instance.class.has_many @paperclip_files, :foreign_key => instance.class.table_name.classify.underscore + '_id' end private :setup_paperclip_files_model - + + def copy_to_local_file(style, dest_path) + File.open(dest_path, 'wb+'){|df| to_file(style).tap{|sf| File.copy_stream(sf, df); sf.close;sf.unlink} } + end + def override_default_options(base) if @options[:url] == base.class.default_options[:url] @options[:url] = ":relative_root/:class/:attachment/:id?style=:style" end @options[:path] = ":database_path" @@ -172,9 +176,10 @@ @queued_for_write = {} end def flush_deletes #:nodoc: ActiveRecord::Base.logger.info("[paperclip] Deleting files for #{name}") + @queued_for_delete.uniq! ##This is apparently necessary for paperclip v 3.x @queued_for_delete.each do |path| /id=([0-9]+)/.match(path) if @options[:cascade_deletion] && !instance.class.exists?(instance.id) raise RuntimeError, "Deletion has not been done by through cascading." if @paperclip_file.exists?($1) else