Eager loading for referenced associations under embedded documents

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0
    • Affects Version/s: 7.1.5
    • Component/s: Query
    • Environment:
      Ruby 2.5.8, Rails 6.0.3.5
    • None
    • None
    • None
    • None
    • None
    • None

      Given the models

      class Family
        include Mongoid::Document
      
        embeds_many :children
      end
      
      class Child
        include Mongoid::Document
      
        embedded_in :family
      
        belongs_to :school
      end
      
      class School
        include Mongoid::Document
      end
      

      I assumed it would be possible to eagerly load the schools of all children in all families, but it threw an exception:

      2.5.8 :004 > Family.all.includes(children: :school).each { |f| p f }
      Traceback (most recent call last):
              1: from (irb):4
      NoMethodError (undefined method `eager_loader' for Mongoid::Association::Embedded::EmbedsMany::Proxy:Class)
      

            Assignee:
            Jamis Buck
            Reporter:
            Leo Arnold
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: