Class

ActiveRecord::Associations::AssociationCollection

Inheritance
< ActiveRecord::Associations::AssociationProxy < Object

AssociationCollection is an abstract class that provides common stuff to ease the implementation of association proxies that represent collections. See the class hierarchy in AssociationProxy.

You need to be careful with assumptions regarding the target: The proxy does not fetch records from the database until it needs them, but new ones created with build are added to the target. So, the target may be non-empty and still lack children waiting to be read from the database. If you look directly to the database you cannot assume that‘s the entire collection because new records may have beed added to the target, etc.

If you need to work on all current children, new and existing records, load_target and the loaded flag are your friends.