<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -25,9 +25,16 @@ to the list of falses for this column.__
 You can specify a specific way a boolean should be stored when 
 assigned with *set_false_as* and *set_true_as*.  This, however, will not change 
 how the value is evaluated on read.  In other words, if you save a false as
-'nope', a value of 0 or 'f' in the database will still be read as a false.
+'nope', a value of '0' or 'f' in the database will still be read as a false.
 It only affects how it is stored.
 
+The values set with set_true_as and set_false_as have to be appropriate 
+for the field type. You, obviously, can't store 'foo' in an integer field.
+Also note that boolean type fields can't have set_false_as or 
+set_true_as set, because booleans are stored differently in different 
+databases (for example: 't' and 'f' in sqlite and 0 and 1 in others).
+However, acts_as_boolean is still useful for booleans, to correctly
+convert something like a -1 to true. 
 
 h3. Parameters
 </diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+require 'active_record/version'
+
 module ActsAsBoolean
   module ClassMethods
 
@@ -20,16 +22,24 @@ module ActsAsBoolean
     # automatically be added to the list of falses for this column.
     #
     # You can specify a specific way a boolean should be stored when 
-    # assigned with set_false_as and set_true_as.  This will not change how
-    # the value is evaluated on read.  In other words, if you save a false as a
-    # 'nope', a value of 0 or 'f' in the database will still be read as a false.
-    # It only affects how it is stored.
+    # assigned with set_false_as and set_true_as parameters.  This will not 
+    # change how the value is evaluated on read.  In other words, if you save 
+    # a false as a 'nope', a value of '0' or 'f' in the database will still be 
+    # read as a false. It only affects how it is stored.
+    #
+    # The values set with set_true_as and set_false_as have to be appropriate 
+    # for the field type. You, obviously, can't store 'foo' in an integer field.
+    # Also note that boolean type fields can't have set_false_as or 
+    # set_true_as set, because booleans are stored differently in different 
+    # databases (for example: 't' and 'f' in sqlite and 0 and 1 in others).  
+    # However, acts_as_boolean is still useful for booleans, to correctly
+    # convert something like a -1 to true.
     #
     # Parameters:
     #
     #   * set_false_as  - What false value to store in the column on assignment.
     #                     By default any value will be stored, and converted to
-    #                     true or false when you read the value.
+    #                     true or false when you read the value.      
     #   * set_true_as   - What true value to store in the column on assignment.
     #                     By default any value will be stored, and converted to
     #                     true or false when you read the value.
@@ -66,26 +76,35 @@ module ActsAsBoolean
       end
 
 
-      if set_false_as or set_true_as # Create setters
-        set_false = set_false_as ? set_false_as.inspect : 'new_value'
-        set_true  = set_true_as  ? set_true_as.inspect  : 'new_value'
+      # Create setters
+      set_false = set_false_as ? set_false_as.inspect : 'new_value'
+      set_true  = set_true_as  ? set_true_as.inspect  : 'new_value'
 
-        args.each do |arg|
-          kode = %Q(
-            def #{arg}=(new_value)
-              if is_true?( new_value #{end_true_call})
-                self[:#{arg}] = #{set_true}
-              else
-                self[:#{arg}] = #{set_false}
-              end
-            end
-          )
-          class_eval kode
+      args.each do |arg|
+
+        # For Rails 2.1 and higher, tell dirty module that we are changing the value
+        if (ActiveRecord::VERSION::MAJOR == 2 and ActiveRecord::VERSION::MINOR &gt;= 1) or
+           (ActiveRecord::VERSION::MAJOR &gt; 2)
+          dirty_code = &quot;#{arg}_will_change!&quot;
         end
-      end 
+
+        kode = %Q(
+          def #{arg}=(new_value)
+            #{dirty_code}
+            
+            if is_true?( new_value #{end_true_call})
+              self[:#{arg}] = #{set_true}
+            else
+              self[:#{arg}] = #{set_false}
+            end
+          end
+        )
+        class_eval kode
+      end
 
 
-      args.each do |arg| # Create getters
+      # Create getters
+      args.each do |arg|
         kode = %Q(
           def #{arg}?
             is_true?( #{arg}_before_type_cast #{end_true_call})</diff>
      <filename>lib/acts_as_boolean.rb</filename>
    </modified>
    <modified>
      <diff>@@ -39,55 +39,56 @@ class ActsAsBooleanTest &lt; Test::Unit::TestCase
     assert !@person.is_true?('f', ['nine', 'nada', 9999])
   end
 
-  def test__false_is_also__should_add_additional_false_consants
-    @person.integer2_boolean = false 
-    assert !@person.integer2_boolean
+  def test_all_should_return_false_by_default_as_nil_is_false
+    assert !@person.boolean_boolean 
+    assert !@person.integer_boolean 
+    assert !@person.string_boolean 
+    assert !@person.float_boolean 
   end
 
   def test_both_read_methods_should_return_the_same_value
-    @person.boolean_boolean = true
-    assert @person.boolean_boolean?
-    assert @person.boolean_boolean
+    @person.string_boolean = true
+    assert @person.string_boolean?
+    assert @person.string_boolean
     
-    @person.boolean_boolean = 0
-    assert !@person.boolean_boolean?
-    assert !@person.boolean_boolean
+    @person.integer_boolean = 0
+    assert !@person.integer_boolean?
+    assert !@person.integer_boolean
 
-    @person.boolean_boolean = -1
-    assert @person.boolean_boolean?
-    assert @person.boolean_boolean
-  end
-  
-  def test_all_should_return_false_as_nil_is_false
-    assert !@person.boolean_boolean 
-    assert !@person.boolean2_boolean 
-    assert !@person.boolean3_boolean 
-    assert !@person.boolean4_boolean 
-    assert !@person.integer_boolean 
-    assert !@person.string_boolean 
+    person = Person.create :integer_boolean =&gt; -1
+    assert person.integer_boolean?
+    assert person.integer_boolean
   end
 
-  def test_value_should_be_stored_as_set_for_non_booleans
-    # If set_true_as or set_false_as aren't set
+  def test__set_false_as__should_add_additional_false_consants
+    person = Person.create :integer2_boolean =&gt; 99
+    assert !person.integer2_boolean
+
+    person = Person.new
+    person.integer3_boolean = 99 
+    assert person.integer3_boolean
+    person.integer3_boolean = 66
+    assert !person.integer3_boolean
+  end
+  
+  def test_value_should_be_stored_as_set_for_non_booleans_if_true_isnt_set
     person = Person.new
     person.integer_boolean = 66
     assert person.integer_boolean?
     assert_equal 66, person.integer_boolean_before_type_cast
 
     person.save
-    assert_equal 66, person.integer_boolean_before_type_cast
+    person.reload
+    assert_equal &quot;66&quot;, person.integer_boolean_before_type_cast
+    assert person.integer_boolean
   end
   
   def test_single__false_is_also__should_return_false
-    @person.boolean4_boolean = 99
-    assert !@person.boolean4_boolean
+    @person.float_boolean = 99
+    assert !@person.float_boolean
 
-    # These shouldn't
-    @person.boolean_boolean = 99
-    assert @person.boolean_boolean
-    
-    @person.boolean4_boolean = 98
-    assert @person.boolean4_boolean
+    @person.float_boolean = 9999 # This shouldn't
+    assert @person.float_boolean
   end
 
   def test_array_for__false_is_also__should_return_false
@@ -107,24 +108,38 @@ class ActsAsBooleanTest &lt; Test::Unit::TestCase
     assert !@person.integer_boolean?
   end
 
-  def test__set_true_as__should_change_how_a_true_value_is_stored_in_db
+  def test__set_true_as__should_change_how_a_true_value_is_stored_in_string_field_in_db
     person = Person.new
-    person.boolean3_boolean = true
     person.string_boolean = true
     person.save
-
-    assert_equal -1, person.boolean3_boolean_before_type_cast
+    person.reload
     assert_equal 'yup', person.string_boolean_before_type_cast
   end
 
-  def test__set_false_as__should_change_how_a_false_value_is_stored_in_db
+  def test__set_true_as__should_change_how_a_true_value_is_stored_in_integer_field_in_db
     person = Person.new
-    person.string_boolean = false
-    person.integer_boolean = false
+    person.integer3_boolean = true
     person.save
+    person.reload
+    assert_equal '-1', person.integer3_boolean_before_type_cast
+  end
 
+  def test__set_false_as__should_change_how_a_false_value_is_stored_in_string_field_in_db 
+    person = Person.new
+    person.string_boolean = false
+    person.save
+    person.reload
     assert_equal 'nope', person.string_boolean_before_type_cast
-    assert_equal 0, person.integer_boolean_before_type_cast
   end
 
+  def test__set_false_as__should_change_how_a_false_value_is_stored_in_integer_field_in_db
+    person = Person.new
+    person.integer3_boolean = false
+    person.save
+    person.reload
+    assert_equal '66', person.integer3_boolean_before_type_cast # Because it's sqlite
+  end
+
+  # !! Need a test to make sure foo_will_change is applied for Rails 2.1 and above, and below still works
+
 end</diff>
      <filename>test/acts_as_boolean_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,11 @@
 class Person &lt; ActiveRecord::Base
   acts_as_boolean  :boolean_boolean,  :boolean2_boolean
-  acts_as_boolean  :boolean3_boolean, :set_true_as =&gt; -1
+
   acts_as_boolean  :string_boolean,   :set_false_as =&gt; 'nope', :set_true_as =&gt; 'yup' 
 
-  acts_as_boolean  :boolean4_boolean, :false_is_also =&gt; 99
+  acts_as_boolean  :float_boolean, :false_is_also =&gt; 99
+
   acts_as_boolean  :integer_boolean,  :set_false_as =&gt; 0, :false_is_also =&gt; ['nine', 'nada', 9999]
   acts_as_boolean  :integer2_boolean, :set_false_as =&gt; 99, :false_is_also =&gt; ['nine', 'nada', 9999]
-  acts_as_boolean  :integer3_boolean, :set_false_as =&gt; 66 
+  acts_as_boolean  :integer3_boolean, :set_false_as =&gt; 66, :set_true_as =&gt; -1
 end</diff>
      <filename>test/person.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,12 +3,12 @@ ActiveRecord::Schema.define :version =&gt; 0 do
   create_table :people, :force =&gt; true do |t|
     t.column :boolean_boolean,  :boolean
     t.column :boolean2_boolean, :boolean
-    t.column :boolean3_boolean, :boolean
-    t.column :boolean4_boolean, :boolean
     t.column :integer_boolean,  :integer
     t.column :integer2_boolean, :integer
     t.column :integer3_boolean, :integer
+    t.column :float_boolean,    :float
     t.column :string_boolean,   :string
+    t.column :string2_boolean,  :string
   end
   
 end</diff>
      <filename>test/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,18 @@ begin
   require File.dirname(__FILE__) + '/../../../../config/environment'
 rescue LoadError
   require 'rubygems'
+
+  # !!TODO Need to automate testing Rails &gt; 2.1 and Rails &lt; 2.1
+  # gem 'activerecord',   '=2.0.2'
+  # gem 'activesupport',  '=2.0.2'
+  # gem 'actionpack',     '=2.0.2'
+  # gem 'activeresource', '=2.0.2'
+
   gem 'activerecord'
   gem 'actionpack'
+  
   require 'active_record'
+  require 'active_record/version'
   require 'action_controller'
 end
 
@@ -18,3 +27,4 @@ ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) +
 ActiveRecord::Base.establish_connection(ENV['DB'] || 'sqlite3')
 
 load(File.dirname(__FILE__) + '/schema.rb')
+</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a3ca451665fce4f43d3f27f3f85b5a23b7793915</id>
    </parent>
  </parents>
  <author>
    <name>Todd Werth</name>
    <email>twerth@infinitered.com</email>
  </author>
  <url>http://github.com/twerth/acts_as_boolean/commit/05f8e6b1373053cc4fe1dec91f17be81cd4da85b</url>
  <id>05f8e6b1373053cc4fe1dec91f17be81cd4da85b</id>
  <committed-date>2008-11-21T09:26:52-08:00</committed-date>
  <authored-date>2008-11-21T09:26:52-08:00</authored-date>
  <message>Fixed a problem with Rails 2.1 and greater; the problem was due to the new Dirty module and partial updates.  Also cleaned up the tests and updated the documenation.</message>
  <tree>a3d781bca16e418a914a32d97b9fc56caa0c26a1</tree>
  <committer>
    <name>Todd Werth</name>
    <email>twerth@infinitered.com</email>
  </committer>
</commit>
