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

foo.bars.length != foo.bars.to_a.length

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

      I've run into a bug where mother.children.length != mother.children.to_a.length in certain situations. A test-case built from a fresh rails-repository is referenced below.

      To reproduce
      1. Setup a mother with associated children
      2. call mother.children.any?
      3. Iterate over the children using render @mother.children
      4. watch how mother.children.length != mother.children.to_a.length

      The problem is related to
      Mongoid::Relations::Targets::Enumerable

      Test case
      Let me know if I should elaborate on how to reproduce the bug. But since it's just a bare Rails repo with minimum new files it shouldn't be too hard to figure it out.

      https://github.com/sandstrom/Mongoid-Bug

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

              Created:
              Updated:
              Resolved: