diff options
Diffstat (limited to 'activerecord/lib/active_record/associations/has_one_association.rb')
-rw-r--r-- | activerecord/lib/active_record/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 9e7f281744..4ccd725ebd 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -18,7 +18,7 @@ module ActiveRecord if replace_existing replace(record, true) else - record[@reflection.primary_key_name] = @owner.id unless @owner.new? + record[@reflection.primary_key_name] = @owner.id unless @owner.new_record? self.target = record end @@ -30,11 +30,11 @@ module ActiveRecord unless @target.nil? if dependent? && !dont_save && @target != obj - @target.destroy unless @target.new? + @target.destroy unless @target.new_record? @owner.clear_association_cache else @target[@reflection.primary_key_name] = nil - @target.save unless @owner.new? || @target.new? + @target.save unless @owner.new_record? || @target.new_record? end end @@ -48,7 +48,7 @@ module ActiveRecord @loaded = true - unless @owner.new? or obj.nil? or dont_save + unless @owner.new_record? or obj.nil? or dont_save return (obj.save ? self : false) else return (obj.nil? ? nil : self) @@ -69,7 +69,7 @@ module ActiveRecord when @reflection.options[:as] @finder_sql = "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_id = #{@owner.quoted_id} AND " + - "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote @owner.class.base_class.name.to_s}" + "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" else @finder_sql = "#{@reflection.table_name}.#{@reflection.primary_key_name} = #{@owner.quoted_id}" end |