From 9f639548e8c98ce96555dd620875243d178fcf88 Mon Sep 17 00:00:00 2001 From: Emily Date: Thu, 13 Oct 2016 13:17:30 +0200 Subject: [PATCH] MONGOID-4315 Get klass when reflecting on association directly instead of using #constantize --- lib/mongoid/criteria/includable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mongoid/criteria/includable.rb b/lib/mongoid/criteria/includable.rb index 08edbfdbb14..89288351578 100644 --- a/lib/mongoid/criteria/includable.rb +++ b/lib/mongoid/criteria/includable.rb @@ -77,7 +77,7 @@ def inclusions=(value) # # @since 5.1.0 def add_inclusion(_klass, relation) - metadata = get_inclusion_metadata(_klass, relation) + metadata = _klass.reflect_on_association(relation) raise Errors::InvalidIncludes.new(_klass, [ relation ]) unless metadata inclusions.push(metadata) unless inclusions.include?(metadata) end @@ -116,7 +116,7 @@ def extract_nested_inclusion(_klass, relation) if _inclusion.is_a?(Array) extract_relations_list(association, _inclusion) else - add_inclusion(association, _inclusion) + add_inclusion(_klass.reflect_on_association(association).klass, _inclusion) end end end