From 49f3525f19a78b478367f997522197d03e8694ce Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Fri, 18 Feb 2011 15:55:55 -0300 Subject: Initialize @target instead asking if it is defined. --- activerecord/lib/active_record/associations/association.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 32eb9ee542..2eb431dfec 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -24,6 +24,7 @@ module ActiveRecord def initialize(owner, reflection) reflection.check_validity! + @target = nil @owner, @reflection = owner, reflection @updated = false @@ -42,7 +43,7 @@ module ActiveRecord # Resets the \loaded flag to +false+ and sets the \target to +nil+. def reset @loaded = false - IdentityMap.remove(@target) if defined?(@target) && @target && IdentityMap.enabled? + IdentityMap.remove(@target) if IdentityMap.enabled? && @target @target = nil end -- cgit v1.2.3