class CollectionProxy
Ruby on Rails 5.2.8.1
Since v4.0.13Association proxies in Active Record are middlemen between the object that holds the association, known as the @owner, and the actual associated object, known as the @target. The kind of association any proxy is about is available in @reflection. That’s an instance of the class ActiveRecord::Reflection::AssociationReflection.
For example, given
class Blog < ActiveRecord::Base has_many :posts end blog = Blog.first
the association proxy in blog.posts has the object in blog as @owner, the collection of its posts as @target, and the @reflection object represents a :has_many macro.
This class delegates unknown methods to @target via method_missing.
The @target object is not \loaded until needed. For example,
blog.posts.count
is computed directly through SQL and does not trigger by itself the instantiation of the actual post records.
Inherits from
Methods (defined here)
- # <<
- # ==
- # any?
- # append
- # build
- # calculate
- # clear
- # concat
- # count
- # create
- # create!
- # delete
- # delete_all
- # destroy
- # destroy_all
- # distinct
- # empty?
- # fifth
- # find
- # first
- # forty_two
- # fourth
- # include?
- # last
- # length
- # loaded?
- # load_target
- # many?
- # new
- # pluck
- # prepend
- # proxy_association
- # push
- # reload
- # replace
- # reset
- # scope
- # second
- # second_to_last
- # select
- # size
- # take
- # target
- # third
- # third_to_last