<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>classy-inheritance.gemspec</filename>
    </added>
    <added>
      <filename>test/test_has_dependency.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,22 @@
+== 0.7.0 2009-04-11
+  * merge all of johnsbrn changes
+== 0.6.8.2 2009-03-19
+  * have fixed problems with class_name ending with ss
+== 0.6.8.1 2009-03-19
+  * Update for Rails 2.3 - johnsbrn
+== 0.6.8 2009-02-03
+  * Make has_one fix consistent with edge Rails - johnsbrn
+== 0.6.7 2009-02-01
+  * Forgot to remove some debugging code -johnsbrn
+== 0.6.6 2009-02-01
+  * More comprehensive fix for has_one bug - johnsbrn
+== 0.6.5 2009-02-01
+  * Add fix for has_one primary key bug - http://rails.lighthouseapp.com/projects/8994/tickets/1756-has_one-with-foreign_key-primary_key-bug - johnsbrn
+== 0.6.4 2009-02-01
+  * Updated deprecated default error messages - johnsbrn
+  * Added has_dependency for non-polymorphic has_one - johnsbrn
+== 0.6.3 2009-01-13
+  * Fixed validations for prefix and postfix - johnsbrn
 == 0.6.2 2008-09-25
   * Added back validates_associated override.
 == 0.6.1 2008-07-21</diff>
      <filename>History.txt</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,114 @@
+require 'active_record/version'
+module ActiveRecord
+  module Associations
+    class HasOneAssociation
+      
+      # this is fixed in 2.3, but it doesn't hurt to leave it here
+      def set_belongs_to_association_for(record)
+        if @reflection.options[:as]
+          record[&quot;#{@reflection.options[:as]}_id&quot;]   = @owner.id unless @owner.new_record?
+          record[&quot;#{@reflection.options[:as]}_type&quot;] = @owner.class.base_class.name.to_s
+        else
+          unless @owner.new_record?
+            primary_key = @reflection.options[:primary_key] || :id
+            record[@reflection.primary_key_name] = @owner.send(primary_key)
+          end
+        end
+      end
+      
+      private 
+      #this is still not fixed in 2.3
+      def new_record(replace_existing)
+        # Make sure we load the target first, if we plan on replacing the existing
+        # instance. Otherwise, if the target has not previously been loaded
+        # elsewhere, the instance we create will get orphaned.
+        load_target if replace_existing
+        record = @reflection.klass.send(:with_scope, :create =&gt; construct_scope[:create]) do
+          yield @reflection
+        end
+
+        if replace_existing
+          replace(record, true) 
+        else
+          unless @owner.new_record?
+            primary_key = @reflection.options[:primary_key] || :id
+            record[@reflection.primary_key_name] = @owner.send(primary_key)
+          end
+          self.target = record
+        end
+
+        record
+      end
+    end
+  end
+  
+  if ActiveRecord::VERSION::MAJOR == 2 &amp;&amp; ActiveRecord::VERSION::MINOR == 3
+
+    module AutosaveAssociation
+    
+      # fix active record has_one primary key bug rails 2.3 - http://rails.lighthouseapp.com/projects/8994/tickets/1756-has_one-with-foreign_key-primary_key-bug
+      def save_has_one_association(reflection)
+        if (association = association_instance_get(reflection.name)) &amp;&amp; !association.target.nil?
+          primary_key = reflection.options[:primary_key] || :id  
+          if reflection.options[:autosave] &amp;&amp; association.marked_for_destruction?
+            association.destroy
+          elsif new_record? || association.new_record? || association[reflection.primary_key_name] != send(primary_key) || reflection.options[:autosave]
+            association[reflection.primary_key_name] = send(primary_key)
+            association.save(false)
+          end
+        end
+      end
+    end
+
+  end
+end
 
 module Stonean
   module ClassyInheritance
-    VERSION = '0.6.4'
+    VERSION = '0.7.0'
 
     def self.version
       VERSION
     end
-
+    
     module ClassMethods
+      
+      
+      # fix active record has_one primary key bug rails 2.2.2 - http://rails.lighthouseapp.com/projects/8994/tickets/1756-has_one-with-foreign_key-primary_key-bug
+      if ActiveRecord::VERSION::MAJOR == 2 &amp;&amp; ActiveRecord::VERSION::MINOR == 2
+
+        def has_one(association_id, options = {})
+          if options[:through]
+            reflection = create_has_one_through_reflection(association_id, options)
+            association_accessor_methods(reflection, ActiveRecord::Associations::HasOneThroughAssociation)
+          else
+            reflection = create_has_one_reflection(association_id, options)
+
+            ivar = &quot;@#{reflection.name}&quot;
+
+            method_name = &quot;has_one_after_save_for_#{reflection.name}&quot;.to_sym
+            define_method(method_name) do
+              association = instance_variable_get(ivar) if instance_variable_defined?(ivar)
+            
+              primary_key = reflection.options[:primary_key] || :id
+              if !association.nil? &amp;&amp; (new_record? || association.new_record? || association[reflection.primary_key_name] != send(primary_key))
+                association[reflection.primary_key_name] = send(primary_key)
+                association.save(true)
+              end
+            end
+            after_save method_name
+
+            add_single_associated_validation_callbacks(reflection.name) if options[:validate] == true
+            association_accessor_methods(reflection, ActiveRecord::Associations::HasOneAssociation)
+            association_constructor_method(:build,  reflection, ActiveRecord::Associations::HasOneAssociation)
+            association_constructor_method(:create, reflection, ActiveRecord::Associations::HasOneAssociation)
+
+            configure_dependency_for_has_one(reflection)
+          end
+        end
+        
+      end
+      
       def depends_on(model_sym, options = {}) 
         define_relationship(model_sym,options)
 
@@ -41,7 +142,10 @@ module Stonean
         options[:attrs].each{|attr| define_accessors(model_sym, attr, options)}
       end
 
-
+      def has_dependency(model_sym, options = {})
+        depends_on(model_sym, options.update(:has_dependency =&gt; true))
+      end
+      
       def can_be(model_sym, options = {})
         unless options[:as]
           raise ArgumentError, &quot;:as attribute required when calling can_be&quot;
@@ -63,7 +167,7 @@ module Stonean
       private
 
       def classy_options
-        [:as, :attrs, :prefix, :postfix, :validates_presence_if, :validates_associated_if]
+        [:as, :attrs, :has_dependency, :prefix, :postfix, :validates_presence_if, :validates_associated_if]
       end
 
       def delete_classy_options(options, *keepers)
@@ -79,6 +183,8 @@ module Stonean
           as_opt = opts.delete(:as)
           opts = polymorphic_constraints(as_opt).merge(opts)
           has_one model_sym, opts
+        elsif options[:has_dependency]
+          has_one model_sym, opts
         else
           belongs_to model_sym, opts
         end
@@ -139,7 +245,7 @@ module Stonean
         if options[:postfix]
           accessor_method_name = (options[:postfix] == true) ? &quot;#{accessor_method_name}_#{model_sym}&quot; : &quot;#{accessor_method_name}_#{options[:postfix]}&quot;
         end
-
+        
         define_method accessor_method_name do
           eval(&quot;self.#{model_sym} ? self.#{model_sym}.#{attr} : nil&quot;)
         end
@@ -177,7 +283,7 @@ if Object.const_defined?(&quot;ActiveRecord&quot;) &amp;&amp; ActiveRecord.const_defined?(&quot;Base&quot;)
   module ActiveRecord::Validations::ClassMethods
 
     def validates_associated_dependent(model_sym, options, configuration = {})
-      configuration = { :message =&gt; I18n.translate('activerecord.errors.messages.invalid'), :on =&gt; :save }.update(configuration)
+      configuration = { :message =&gt; I18n.translate('activerecord.errors.messages')[:invalid], :on =&gt; :save }.update(configuration)
 
       validates_each(model_sym, configuration) do |record, attr_name, value|
         associate = record.send(attr_name)
@@ -195,9 +301,9 @@ if Object.const_defined?(&quot;ActiveRecord&quot;) &amp;&amp; ActiveRecord.const_defined?(&quot;Base&quot;)
       end
     end
   end
-                                    
-
+  
   ActiveRecord::Base.class_eval do
     extend Stonean::ClassyInheritance::ClassMethods
   end
+  
 end</diff>
      <filename>lib/classy-inheritance.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,9 @@
 require File.dirname(__FILE__) + '/test_helper.rb'
 
-User.depends_on :profile, :attrs =&gt; [:first_name, :last_name, :email]
-
 class TestClassyInheritance &lt; Test::Unit::TestCase
 
   def setup
+    User.depends_on :profile, :attrs =&gt; [:first_name, :last_name, :email]
     @user = User.new
   end
   </diff>
      <filename>test/test_classy-inheritance.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 require 'rubygems'
 require 'activerecord'
 
+ActiveRecord.load_all!
+
 require 'test/unit'
 require File.dirname(__FILE__) + '/../lib/classy-inheritance'
 
@@ -19,6 +21,22 @@ class SetupTestTables &lt; ActiveRecord::Migration
       t.timestamps
     end
     
+    create_table :accounts, :force =&gt; true do |t|
+      t.string :first_name
+      t.string :last_name
+      t.string :email
+
+      t.timestamps
+    end
+    
+    create_table :account_logins, :force =&gt; true do |t|
+      t.string :login
+      t.string :password
+      t.string :account_email
+
+      t.timestamps
+    end
+    
     create_table :users, :force =&gt; true do |t|
       t.string :login
       t.integer :profile_id
@@ -40,6 +58,17 @@ class SetupTestTables &lt; ActiveRecord::Migration
       t.timestamps
     end
 
+    create_table :databases, :force =&gt; true do |t|
+      t.string :name
+      t.timestamps
+    end
+    
+    create_table :database_logins, :force =&gt; true do |t|
+      t.string :login
+      t.integer :database_id
+      t.timestamps
+    end
+    
     create_table :addresses, :force =&gt; true do |t|
       t.string :line_one
       t.string :line_two
@@ -84,6 +113,8 @@ class SetupTestTables &lt; ActiveRecord::Migration
   end
   
   def self.down
+    drop_table :accounts
+    drop_table :account_logins
     drop_table :authors
     drop_table :artists
     drop_table :users
@@ -102,6 +133,22 @@ class Profile &lt; ActiveRecord::Base
   validates_presence_of :first_name, :last_name, :email
 end
 
+class Database &lt; ActiveRecord::Base
+  validates_presence_of :name
+end
+
+class DatabaseLogin &lt; ActiveRecord::Base
+  validates_presence_of :login
+end
+
+class Account &lt; ActiveRecord::Base
+  validates_presence_of :first_name, :last_name, :email
+end
+
+class AccountLogin &lt; ActiveRecord::Base
+  validates_presence_of :login, :password
+end
+
 class User &lt; ActiveRecord::Base
   validates_presence_of :login
 end</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,17 @@
 require File.dirname(__FILE__) + '/test_helper.rb'
 
 class TestWithOptionalDependency &lt; Test::Unit::TestCase
-  # Turn off the validates_presence_of call
-  Author.depends_on :profile, :validates_presence_if =&gt; false, 
-    :attrs =&gt; [:first_name, :last_name, :email]
-  
-  # Turn off the validates_presence_of and the validates_associated calls
-  Artist.depends_on :profile, :validates_presence_if =&gt; false, 
-    :validates_associated_if =&gt; false,
-    :attrs =&gt; [:first_name, :last_name, :email]
 
   def setup
+    # Turn off the validates_presence_of call
+    Author.depends_on :profile, :validates_presence_if =&gt; false, 
+      :attrs =&gt; [:first_name, :last_name, :email]
+
+    # Turn off the validates_presence_of and the validates_associated calls
+    Artist.depends_on :profile, :validates_presence_if =&gt; false, 
+      :validates_associated_if =&gt; false,
+      :attrs =&gt; [:first_name, :last_name, :email]
+    
     @author = Author.new
     @artist = Artist.new
   end</diff>
      <filename>test/test_with_optional_dependency.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8c291ff6108611bc74878897565c5548ad99d619</id>
    </parent>
  </parents>
  <author>
    <name>Andrew Stone</name>
    <email>andy@stonean.com</email>
  </author>
  <url>http://github.com/stonean/classy-inheritance/commit/55820a8ce0c756660ff0aa704882c6b78a903c99</url>
  <id>55820a8ce0c756660ff0aa704882c6b78a903c99</id>
  <committed-date>2009-04-11T10:09:27-07:00</committed-date>
  <authored-date>2009-04-11T10:09:27-07:00</authored-date>
  <message>merge from Brian Johnson.  lots of good stuff</message>
  <tree>571d8e33b7805543a0b2713f9bfd9e4e40b15a50</tree>
  <committer>
    <name>Andrew Stone</name>
    <email>andy@stonean.com</email>
  </committer>
</commit>
