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

Embedded document class removal causes NameError on old data.

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

      Perhaps the following change to automatically create a class including MongoId::Document would be a reasonable alternative to the above issue?

      mongoid-2.4.4/lib/mongoid/relations/metadata.rb:

            def klass
              begin
                @klass||= class_name.constantize
              rescue NameError => e
                c = Class.new do
                  include Mongoid::Document
                end
                Kernel.const_set class_name, c
                  
                @klass= class_name.constantize
              end
              @klass
            end
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            thedracle thedracle
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: