class ActiveRecord::Associations::CollectionAssociation
def reader
:nodoc:
+load_target+ and the +loaded+ flag are your friends.
If you need to work on all current children, new and existing records,
collection because new records may have been added to the target, etc.
If you look directly to the database you cannot assume that's the entire
non-empty and still lack children waiting to be read from the database.
ones created with +build+ are added to the target. So, the target may be
does not fetch records from the database until it needs them, but new
You need to be careful with assumptions regarding the target: The proxy
the +:through association+ option.
defined by +has_and_belongs_to_many+, +has_many+ or +has_many+ with
The CollectionAssociation class provides common methods to the collections
HasManyThroughAssociation + ThroughAssociation => has_many :through
HasManyAssociation => has_many
CollectionAssociation:
collections. See the class hierarchy in Association.
ease the implementation of association proxies that represent
CollectionAssociation is an abstract class that provides common stuff to
= Active Record Association Collection
def reader ensure_klass_exists! if stale_target? reload end @proxy ||= CollectionProxy.create(klass, self) @proxy.reset_scope end