<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/rails_root/app/models/abstract.rb</filename>
    </added>
    <added>
      <filename>test/unit/abstract_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -377,7 +377,17 @@ module Fleximage
       # Delete the image file for this record. This is automatically ran after this record gets 
       # destroyed, but you can call it manually if you want to remove the image from the record.
       def delete_image_file
-        File.delete(file_path) if !self.class.db_store? &amp;&amp; File.exists?(file_path)
+        return unless self.class.has_store?
+        
+        if self.class.db_store?
+          update_attribute :image_file_data, nil unless frozen?
+        else
+          File.delete(file_path) &amp;&amp; File.exists?(file_path)
+        end
+        
+        clear_magic_attributes
+        
+        self
       end
       
       # Execute image presence and validity validations.
@@ -434,6 +444,14 @@ module Fleximage
           end
         end
         
+        def clear_magic_attributes
+          unless frozen?
+            self.image_filename = nil if respond_to?(:image_filename=)
+            self.image_width    = nil if respond_to?(:image_width=)
+            self.image_height   = nil if respond_to?(:image_height=)
+          end
+        end
+        
         # If any magic column names exists fill them with image meta data.
         def set_magic_attributes(file = nil)
           if file &amp;&amp; self.respond_to?(:image_filename=)</diff>
      <filename>lib/fleximage/model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,4 +16,15 @@ class FleximageMagicColumnsTest &lt; Test::Unit::TestCase
   rescue SocketError
     print '!'
   end
+  
+  def test_should_delete_magic_columns_when_image_is_deleted
+    p = PhotoFile.new(:image_file =&gt; files(:photo))
+    p.save
+    
+    p = PhotoFile.find(p.id)
+    p.delete_image_file.save
+    
+    assert_nil p.image_width
+    assert_nil p.image_height
+  end
 end</diff>
      <filename>test/unit/magic_columns_test.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/unit/default_image_option_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>6c6051daa04dc5b5eb419275bf33b7710c842bea</id>
    </parent>
  </parents>
  <author>
    <name>Alex Wayne</name>
    <email>alex@beautifulpixel.com</email>
  </author>
  <url>http://github.com/Squeegy/fleximage/commit/192ddcb95af577e9e390ea13b24fa27470844d32</url>
  <id>192ddcb95af577e9e390ea13b24fa27470844d32</id>
  <committed-date>2008-06-09T20:50:21-07:00</committed-date>
  <authored-date>2008-06-09T20:50:21-07:00</authored-date>
  <message>Fixed that an error would sometimes occur on deleting an abstract image model.  Also, magic columns are cleared when #delete_image_file is called.  [#2 status:resolved]</message>
  <tree>93058d175e4a9751d4340c7c376419b624297ebf</tree>
  <committer>
    <name>Alex Wayne</name>
    <email>alex@beautifulpixel.com</email>
  </committer>
</commit>
