rails/rails — pull request #7983 by georgebrock (2012-10-18 07:39:25+00:00)
Title: Backport 4bc2ae0 to fix #7950

An unsaved parent shouldn't say that it's children include any child with a nil
foreign key:

child = Child.create(parent_id: nil)
Parent.new.children.include?(child) # => false

Adds a test and fixes it by backporting 4bc2ae0da1dd812aee759f6d13ad428354cd0e13.

See #7950 for the original issue, and #7959 for an attempted fix (before I realised it was already fixed on master) and discussion of backporting.