Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5052

Eager loading for referenced associations under embedded documents

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Backlog
    • Major - P3
    • Resolution: Unresolved
    • 7.1.5
    • None
    • Query
    • Ruby 2.5.8, Rails 6.0.3.5

    Description

      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)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            larnold@givve.com Leo Arnold
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated: