From a8450ae7a1b64fa9b5e555682dd67ddb988f38af Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Fri, 12 Jun 2009 17:30:56 -0300 Subject: [PATCH] HasOneAssociation should inherits from AssociationProxy not BelongsToAssociation. --- .../associations/has_one_association.rb | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index b72b843..c2568d0 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -1,6 +1,6 @@ module ActiveRecord module Associations - class HasOneAssociation < BelongsToAssociation #:nodoc: + class HasOneAssociation < AssociationProxy #:nodoc: def initialize(owner, reflection) super construct_sql @@ -77,7 +77,7 @@ module ActiveRecord the_target = @reflection.klass.find(:first, :conditions => @finder_sql, :select => @reflection.options[:select], - :order => @reflection.options[:order], + :order => @reflection.options[:order], :include => @reflection.options[:include], :readonly => @reflection.options[:readonly] ) @@ -88,7 +88,7 @@ module ActiveRecord def construct_sql case when @reflection.options[:as] - @finder_sql = + @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " + "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" else @@ -96,7 +96,7 @@ module ActiveRecord end @finder_sql << " AND (#{conditions})" if conditions end - + def construct_scope create_scoping = {} set_belongs_to_association_for(create_scoping) @@ -113,7 +113,7 @@ module ActiveRecord end if replace_existing - replace(record, true) + replace(record, true) else record[@reflection.primary_key_name] = @owner.id unless @owner.new_record? self.target = record -- 1.6.0.4