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

Building record with has_one and polymorphic associations

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

      class A
        include Mongoid::Document
        belongs_to :b
        belongs_to :pol, :polymorphic => true
      end
      
      class B
        include Mongoid::Document
        has_many :a
      end
      
      class C
        include Mongoid::Document
        has_one :a, :as => :pol   # BTW, problem disappear with has_many
      end
      
      A.create(:b => B.create, :pol => C.create)
      # The error occurred while evaluating nil.push
      # … /.rvm/gems/ruby-1.9.2-head/gems/mongoid-2.1.2/lib/mongoid/relations/bindings/referenced/in.rb:32:in `block in bind'
      
      A.create(:pol => C.create, :b => B.create)
      # OK
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            AlexanderPavlenko AlexanderPavlenko [X]
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: