<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/fixtures/group.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,7 @@
+[20 Sep 07]
+
+* Remove ability to set defaults with defaults instance method. Too easy to override values from parameters.
+
 [25 Jul 07]
 
 * Using a symbol as a default value will cause the return value of the method with that name to be the default.</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -11,28 +11,16 @@ If you find this plugin useful, please consider a donation to show your support!
 Allow you to easily specify default values for attributes on new model objects. Eg:
 
   class Person &lt; ActiveRecord::Base
-    defaults :country =&gt; 'New Zealand', :type =&gt; 'Unknown'
+    defaults :country =&gt; 'New Zealand', :type =&gt; 'Unknown', :address =&gt; proc { Address.new }
     
     default :last_name do |person|
       person.first_name
     end
   end
   
-You can also define a defaults method like so:
+The default value is only used if the attribute is not present in the attributes hash.
 
-  class Person &lt; ActiveRecord::Base
-    def defaults
-      self.first_name = &quot;Jonathan&quot;
-    end
-  end
-  
-The default value is only used if the attribute is not present in the attributes hash:
-
-  p = Person.new
-  p.country # &quot;New Zealand&quot;
-  
-  p = Person.new(:country =&gt; nil)
-  p.country # nil
+See active_record_defaults.rb for full documentation.
   
 == Installation
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -95,17 +95,19 @@ module ActiveRecord
             
             # Ignore a default value for association_id if association has been specified
             reflection = self.class.reflections[default.attribute.to_sym]
-            next if reflection and reflection.macro == :belongs_to and attribute_keys.include?(reflection.primary_key_name)
+            if reflection and reflection.macro == :belongs_to and attribute_keys.include?(reflection.primary_key_name)
+              next
+            end
             
             # Ignore a default value for association if association_id has been specified
             reflection = self.class.reflections.values.find { |r| r.respond_to?(:primary_key_name) &amp;&amp; r.primary_key_name == default.attribute }
-            next if reflection and reflection.macro == :belongs_to and attribute_keys.include?(reflection.name.to_s)
+            if reflection and reflection.macro == :belongs_to and attribute_keys.include?(reflection.name.to_s)
+              next
+            end
             
             send(&quot;#{default.attribute}=&quot;, default.value(self))
           end
         end
-        
-        defaults if respond_to?(:defaults)
       end
     end
     </diff>
      <filename>lib/active_record_defaults.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,7 @@
 require 'test/unit'
 
 begin
-  require File.dirname(__FILE__) + '/../../../../config/boot'
-  Rails::Initializer.run
+  require File.dirname(__FILE__) + '/../../../../config/environment'
 rescue LoadError
   require 'rubygems'
   require_gem 'activerecord'
@@ -10,11 +9,7 @@ end
 
 # Search for fixtures first
 fixture_path = File.dirname(__FILE__) + '/fixtures/'
-begin
-  Dependencies.load_paths.insert(0, fixture_path)
-rescue
-  $LOAD_PATH.unshift(fixture_path)
-end
+Dependencies.load_paths.insert(0, fixture_path)
 
 require 'active_record/fixtures'
 </diff>
      <filename>test/abstract_unit.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,4 @@
 require File.dirname(__FILE__) + '/abstract_unit'
-require File.dirname(__FILE__) + '/fixtures/address'
-require File.dirname(__FILE__) + '/fixtures/school'
-require File.dirname(__FILE__) + '/fixtures/person'
-require File.dirname(__FILE__) + '/fixtures/person_with_default_school_id'
-require File.dirname(__FILE__) + '/fixtures/person_with_default_school'
 
 class ActiveRecordDefaultsTest &lt; Test::Unit::TestCase
   fixtures :people, :schools
@@ -36,7 +31,7 @@ class ActiveRecordDefaultsTest &lt; Test::Unit::TestCase
   end
   
   def test_default_relying_on_previous_default
-    assert_equal Date.new(2006, 10, 2), Person.new.birthdate
+    assert_equal &quot;Red&quot;, Person.new(:last_name =&gt; 'Carter').favourite_colour
   end
   
   def test_defaults_on_create
@@ -50,10 +45,6 @@ class ActiveRecordDefaultsTest &lt; Test::Unit::TestCase
     assert_equal 'Blue', p.favourite_colour
   end
   
-  def test_defaults_from_method
-    assert_equal Date.new(2006, 10, 5), Person.new(:lucky_number =&gt; 5).birthdate
-  end
-  
   def test_default_belongs_to_association
     assert_equal School.find(1), PersonWithDefaultSchool.new.school
   end
@@ -69,4 +60,8 @@ class ActiveRecordDefaultsTest &lt; Test::Unit::TestCase
   def test_specific_belong_to_association_overrides_default_foreign_key_value
     assert_nil PersonWithDefaultSchoolId.new(:school =&gt; nil).school
   end
+  
+  def test_initialize_model_without_any_defaults
+    assert_nothing_raised { Group.new }
+  end
 end</diff>
      <filename>test/active_record_defaults_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,9 @@
 class Person &lt; ActiveRecord::Base
+  belongs_to :school
+  
+  # Include an aggregate reflection to check compatibility
+  composed_of :address, :mapping =&gt; [%w(address_suburb suburb), %{address_city city}]
+  
   defaults :city =&gt; 'Christchurch', :country =&gt; Proc.new { 'New Zealand' }
   
   default :first_name =&gt; 'Sean'
@@ -7,18 +12,9 @@ class Person &lt; ActiveRecord::Base
     'Fitzpatrick'
   end
   
-  defaults :lucky_number =&gt; lambda { 2 }, :favourite_colour =&gt; :default_favourite_colour
-  
-  def defaults
-    self.birthdate = Date.new(2006, 10, lucky_number) if lucky_number?
-  end
+  defaults :lucky_number =&gt; proc { 2 }, :favourite_colour =&gt; :default_favourite_colour
   
   def default_favourite_colour
-    &quot;Blue&quot;
+    last_name == 'Fitzpatrick' ? &quot;Blue&quot; : &quot;Red&quot;
   end
-  
-  # Include an aggregate reflection to check compatibility
-  composed_of :address, :mapping =&gt; [%w(address_suburb suburb), %{address_city city}]
-  
-  belongs_to :school
 end</diff>
      <filename>test/fixtures/person.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5c8ca5a3de0fb8bd543e7339b9cf2bcdd32ceefb</id>
    </parent>
  </parents>
  <author>
    <name>jonathan</name>
    <email>jonathan@20afb1e0-9c0e-0410-9884-91ed27886737</email>
  </author>
  <url>http://github.com/aussiegeek/active_record_defaults/commit/b7e1977743e9e4462c55849c3e2b26c51be8bf28</url>
  <id>b7e1977743e9e4462c55849c3e2b26c51be8bf28</id>
  <committed-date>2007-09-20T03:25:16-07:00</committed-date>
  <authored-date>2007-09-20T03:25:16-07:00</authored-date>
  <message>

git-svn-id: http://svn.viney.net.nz/things/rails/plugins/active_record_defaults@313 20afb1e0-9c0e-0410-9884-91ed27886737</message>
  <tree>3877a0a1ede1b53e5e631c7fec61640b26bc4852</tree>
  <committer>
    <name>jonathan</name>
    <email>jonathan@20afb1e0-9c0e-0410-9884-91ed27886737</email>
  </committer>
</commit>
