Skip to content

Commit

Permalink
MONGOID-4315 Get klass when reflecting on association directly instea…
Browse files Browse the repository at this point in the history
…d of using #constantize
  • Loading branch information
estolfo committed Oct 13, 2016
1 parent 2c46131 commit 9f63954
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/mongoid/criteria/includable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9f63954

Please sign in to comment.