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

eager_loaded failed undefined method `stores_foreign_key?' for nil:NilClass

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.2
    • Affects Version/s: None
    • Component/s: None

      Mongoid 3.0.1

      Query code:

      @topic= Topic.includes(:replies => [:user]).where(:_id => params[:id]).first
      

      That code can run in 3.0.0.rc, but not 3.0.1

      Error messages:

      undefined method `stores_foreign_key?' for nil:NilClass
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:538:in `eager_loaded_ids'
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:519:in `block in eager_load'
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:518:in `reject!'
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:518:in `eager_load'
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:653:in `block in with_eager_loading'
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:632:in `selecting'
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:650:in `with_eager_loading'
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:200:in `first'
           # /Users/jason/.rvm/gems/ruby-1.9.3-p0/gems/mongoid-3.0.1/lib/mongoid/contextual.rb:18:in `first'
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            huacnlee@gmail.com Jason Lee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: