Type:
Class

Association 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.

first

first(*args) Instance Public methods Returns the first record, or the first

2015-06-20 00:00:00
append

append(*records) Instance Public methods Alias for:

2015-06-20 00:00:00
replace

replace(other_array) Instance Public methods Replaces this collection with

2015-06-20 00:00:00
find

find(*args, &block) Instance Public methods Finds an object in the collection

2015-06-20 00:00:00
scope

scope() Instance Public methods Returns a Relation object for the

2015-06-20 00:00:00
new

new(attributes = {}, &block) Instance Public methods Alias for:

2015-06-20 00:00:00
push

push(*records) Instance Public methods Alias for:

2015-06-20 00:00:00
build

build(attributes = {}, &block) Instance Public methods Returns a new object

2015-06-20 00:00:00
fourth

fourth(*args) Instance Public methods Same as first except returns

2015-06-20 00:00:00
fifth

fifth(*args) Instance Public methods Same as first except returns

2015-06-20 00:00:00