mongodb/mongoid · error · ArgumentError
Eager loading only supports arguments that are the names of
Error message
Eager loading only supports arguments that are the names of associations on #{klass} What it means
Error "Eager loading only supports arguments that are the names of associations on #{klass}" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/criteria/includable.rb:141
# @param [ Class ] parent_class The class to start the lookup from.
# @param [ Symbol | String ] relation The association name.
# @param [ Boolean ] is_eager_load Whether to consider subclasses.
#
# @return [ Array<Mongoid::Association::Relatable> ] Matching associations.
def resolve_inclusion_associations(parent_class, relation, is_eager_load)
if association = parent_class.reflect_on_association(relation)
return [ association ]
end
return [] unless is_eager_load
parent_class.descendants.filter_map { |sub| sub.reflect_on_association(relation) }
end
end
def raise_eager_error(is_eager_load, klass, relation)
if is_eager_load
raise ArgumentError, "Eager loading only supports arguments that are the names of associations on #{klass}"
end
raise Errors::InvalidIncludes.new(klass, [ relation ])
end
end
end
View on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/criteria/includable.rb:141 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23).
Data as JSON: /api/errors/f76e5643dd086b41.
Report an issue: GitHub.