From 96cc08f24b0d1576573e09500faa4a9fd106f44e Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 14 Oct 2010 15:09:44 -0300 Subject: Check if constant is defined in AR, if not this can cause errors when using polymorphic associations. --- activerecord/lib/active_record/associations/association_proxy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 52cb164550..cb8d8b4a7b 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -254,7 +254,7 @@ module ActiveRecord return nil unless defined?(@loaded) if !loaded? and (@owner.persisted? || foreign_key_present) - if IdentityMap.enabled? && defined?(@reflection.klass) + if IdentityMap.enabled? && ActiveRecord.const_defined?(@reflection.class_name) @target = IdentityMap.get(@reflection.klass, @owner[@reflection.association_foreign_key]) end @target ||= find_target -- cgit v1.2.3