When using .includes on a belongs_to relation that has nil values the following exception is thrown:
Failure/Error: doc.set_relation(@metadata.name, element)
NoMethodError:
undefined method `set_relation' for nil:NilClass
Did you mean? set_trace_func
Checking for nil doc in Mongoid::Eager::Relations seems to resolve the issue:
def set_relation(doc, element)
doc.set_relation(@metadata.name, element) unless doc.blank?
end
- is duplicated by
-
MONGOID-4317 Nested eager loading fails with nils
- Closed