mongoid/mongoid — Issue #1732: double the number of objects from has_many association when enumerating
Author: gpolyn
Created: 2012-02-19 14:54:04+00:00
State: open

Using 2.4.4, #each loops through my has_many association objects twice:

class Parent

has_many :items, :class_name=>"Something::Item", as: :itemizable, dependent: :nullify

...

class Something::Item

belongs_to :itemizable, polymorphic: true

...

In parent...

times_run = 0
p "items size #{items.size}"
items.each do |pl|
times_run += 1
p "item #{pl}"
end
p "times run #{times_run}"

result...

"items size 3"
"item #"
"item #"
"item #"
"item #"
"item #"
"item #"
"times run 6"

thx, g