mongoid/mongoid — pull request #3226 by sleepingkingstudios (2013-08-20 02:37:49+00:00)
Title: Changed @_children to @__children

As-is, when calling Changeable#move_changes, it would overwrite the @_children
instance variable with nil. This caused a children *relation* to return nil
after the parent was saved.

class Tree
include Mongoid::Document

belongs_to :parent, :class_name => "Tree", :inverse_of => :children
has_many :children, :class_name => "Tree", :inverse_of => :parent
end

> instance = Tree.new
> instance.children
=> []
> instance.save
=> true
> instance.children
=> nil

> parent = Tree.new
> parent.save
=> true
> child = Tree.new
> child.parent = parent
=> NoMethodError: undefined method `push' for nil:NilClass
from /lib/mongoid/relations/bindings/referenced/in.rb:29:in
`block in bind_one'