<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -62,6 +62,9 @@ module Paperclip
     # If the file that is assigned is not valid, the processing (i.e.
     # thumbnailing, etc) will NOT be run.
     def assign uploaded_file
+      # This is because of changes in Rails 2.3 that cause blank fields to send nil
+      return nil if uploaded_file.nil?
+
       %w(file_name).each do |field|
         unless @instance.class.column_names.include?(&quot;#{name}_#{field}&quot;)
           raise PaperclipError.new(&quot;#{@instance.class} model does not have required column '#{name}_#{field}'&quot;)
@@ -158,6 +161,23 @@ module Paperclip
       end
     end
 
+    # Clears out the attachment. Has the same effect as previously assigning
+    # nil to the attachment. Does NOT save. If you wish to clear AND save,
+    # use #destroy.
+    def clear
+      queue_existing_for_delete
+      @errors            = {}
+      @validation_errors = nil
+    end
+
+    # Destroys the attachment. Has the same effect as previously assigning
+    # nil to the attachment *and saving*. This is permanent. If you wish to
+    # wipe out the existing attachment but not save, use #clear.
+    def destroy
+      clear
+      save
+    end
+
     # Returns the name of the file as originally assigned, and lives in the
     # &lt;attachment&gt;_file_name attribute of the model.
     def original_filename
@@ -273,7 +293,7 @@ module Paperclip
     end
 
     def valid_assignment? file #:nodoc:
-      file.nil? || (file.respond_to?(:original_filename) &amp;&amp; file.respond_to?(:content_type))
+      file.respond_to?(:original_filename) &amp;&amp; file.respond_to?(:content_type)
     end
 
     def validate #:nodoc:</diff>
      <filename>lib/paperclip/attachment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -592,20 +592,39 @@ class AttachmentTest &lt; Test::Unit::TestCase
               file.close
             end
 
-            context &quot;and deleted&quot; do
+            context &quot;and trying to delete&quot; do
               setup do
                 @existing_names = @attachment.styles.keys.collect do |style|
                   @attachment.path(style)
                 end
+              end
+
+              should &quot;not delete the files saving in a deprecated manner&quot; do
+                @attachment.expects(:instance_write).with(:file_name, nil).never
+                @attachment.expects(:instance_write).with(:content_type, nil).never
+                @attachment.expects(:instance_write).with(:file_size, nil).never
+                @attachment.expects(:instance_write).with(:updated_at, nil).never
+                @attachment.assign nil
+                @attachment.save
+                @existing_names.each{|f| assert File.exists?(f) }
+              end
+
+              should &quot;delete the files when you call #clear and #save&quot; do
                 @attachment.expects(:instance_write).with(:file_name, nil)
                 @attachment.expects(:instance_write).with(:content_type, nil)
                 @attachment.expects(:instance_write).with(:file_size, nil)
                 @attachment.expects(:instance_write).with(:updated_at, nil)
-                @attachment.assign nil
+                @attachment.clear
                 @attachment.save
+                @existing_names.each{|f| assert ! File.exists?(f) }
               end
 
-              should &quot;delete the files&quot; do
+              should &quot;delete the files when you call #delete&quot; do
+                @attachment.expects(:instance_write).with(:file_name, nil)
+                @attachment.expects(:instance_write).with(:content_type, nil)
+                @attachment.expects(:instance_write).with(:file_size, nil)
+                @attachment.expects(:instance_write).with(:updated_at, nil)
+                @attachment.destroy
                 @existing_names.each{|f| assert ! File.exists?(f) }
               end
             end</diff>
      <filename>test/attachment_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -96,7 +96,7 @@ class IntegrationTest &lt; Test::Unit::TestCase
 
       context &quot;and deleted&quot; do
         setup do
-          @dummy.avatar = nil
+          @dummy.avatar.clear
           @dummy.save
         end
 
@@ -235,7 +235,7 @@ class IntegrationTest &lt; Test::Unit::TestCase
         assert File.exists?(p)
       end
 
-      @dummy.avatar = nil
+      @dummy.avatar.clear
       assert_nil @dummy.avatar_file_name
       assert @dummy.valid?
       assert @dummy.save
@@ -258,7 +258,7 @@ class IntegrationTest &lt; Test::Unit::TestCase
 
       saved_paths = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.path(s) }
 
-      @d2.avatar = nil
+      @d2.avatar.clear
       assert @d2.save
 
       saved_paths.each do |p|
@@ -266,7 +266,7 @@ class IntegrationTest &lt; Test::Unit::TestCase
       end
     end
 
-    should &quot;know the difference between good files, bad files, not files, and nil&quot; do
+    should &quot;know the difference between good files, bad files, and not files&quot; do
       expected = @dummy.avatar.to_file
       @dummy.avatar = &quot;not a file&quot;
       assert @dummy.valid?
@@ -275,25 +275,21 @@ class IntegrationTest &lt; Test::Unit::TestCase
 
       @dummy.avatar = @bad_file
       assert ! @dummy.valid?
-      @dummy.avatar = nil
-      assert @dummy.valid?, @dummy.errors.inspect 
     end
 
-    should &quot;know the difference between good files, bad files, not files, and nil when validating&quot; do
+    should &quot;know the difference between good files, bad files, and not files when validating&quot; do
       Dummy.validates_attachment_presence :avatar
       @d2 = Dummy.find(@dummy.id)
       @d2.avatar = @file
       assert   @d2.valid?, @d2.errors.full_messages.inspect 
       @d2.avatar = @bad_file
       assert ! @d2.valid?
-      @d2.avatar = nil
-      assert ! @d2.valid?
     end
 
     should &quot;be able to reload without saving and not have the file disappear&quot; do
       @dummy.avatar = @file
       assert @dummy.save
-      @dummy.avatar = nil
+      @dummy.avatar.clear
       assert_nil @dummy.avatar_file_name
       @dummy.reload
       assert_equal &quot;5k.png&quot;, @dummy.avatar_file_name
@@ -316,16 +312,6 @@ class IntegrationTest &lt; Test::Unit::TestCase
         assert_equal `identify -format &quot;%wx%h&quot; &quot;#{@dummy.avatar.path(:original)}&quot;`,
                      `identify -format &quot;%wx%h&quot; &quot;#{@dummy2.avatar.path(:original)}&quot;`
       end
-      
-      should &quot;work when assigned a nil file&quot; do
-        @dummy2.avatar = nil
-        @dummy2.save
-
-        @dummy.avatar = @dummy2.avatar
-        @dummy.save
-        
-        assert !@dummy.avatar?
-      end
     end    
 
   end
@@ -423,7 +409,7 @@ class IntegrationTest &lt; Test::Unit::TestCase
           assert key.exists?
         end
 
-        @dummy.avatar = nil
+        @dummy.avatar.clear
         assert_nil @dummy.avatar_file_name
         assert @dummy.valid?
         assert @dummy.save
@@ -446,7 +432,7 @@ class IntegrationTest &lt; Test::Unit::TestCase
 
         saved_keys = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.to_file(s) }
 
-        @d2.avatar = nil
+        @d2.avatar.clear
         assert @d2.save
 
         saved_keys.each do |key|</diff>
      <filename>test/integration_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f44ede70f849acf3ae3403cc1d5e1439fa0fac91</id>
    </parent>
  </parents>
  <author>
    <name>Jon Yurek</name>
    <email>jyurek@thoughtbot.com</email>
  </author>
  <url>http://github.com/thoughtbot/paperclip/commit/2db00be2e137c1fd8d69c35dd3e56ada28c511b1</url>
  <id>2db00be2e137c1fd8d69c35dd3e56ada28c511b1</id>
  <committed-date>2009-03-12T12:13:48-07:00</committed-date>
  <authored-date>2009-03-12T12:06:25-07:00</authored-date>
  <message>Removed the ability for nil to delete an attachment, sadly.</message>
  <tree>8c24a533f891d64223898c028a8fffb40f239a24</tree>
  <committer>
    <name>Jon Yurek</name>
    <email>jyurek@thoughtbot.com</email>
  </committer>
</commit>
