Skip to content
Browse files

Check if constant is defined in AR, if not this can cause errors when…

… using polymorphic associations.
  • Loading branch information...
1 parent 0873d1e commit 96cc08f24b0d1576573e09500faa4a9fd106f44e @miloops miloops committed Oct 14, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/associations/association_proxy.rb
View
2 activerecord/lib/active_record/associations/association_proxy.rb
@@ -254,7 +254,7 @@ def load_target
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

0 comments on commit 96cc08f

Please sign in to comment.
Something went wrong with that request. Please try again.