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

nil problem for some embedded collections

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

      Hi,

      An embedded collection used in conjunction with class inheritance produce a nil error for some documents in our database (not all):

      • undefined method `[]' for nil:NilClass
        when accessed. There is data in the database for the embedded collection and it looks OK. It only does this for a minority of the documents. Please let me know if you have any tips on how to debug this.

      The embedded collection use inheritance like this:

      class CacheBase
        include Mongoid::Document
        include Mongoid::Timestamps
      
        embedded_in :cachebase_cacheable, polymorphic: true
      end
      
      class A < CacheBase
      
      end
      
      class C
        include Mongoid::Document
        include Mongoid::Timestamps
      
         embeds_many :a_interactions, :class_name => "A", as: :cachebase_cacheable
      
      end
      

      Please let me know if you have any tips on how to debug this or what the cause may be.

            Assignee:
            durran Durran Jordan
            Reporter:
            digitalplaywright digitalplaywright
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: