class ActiveRecord::AssociationRelation

Public Class Methods

new(klass, association, **) click to toggle source
Calls superclass method
# File lib/active_record/association_relation.rb, line 5
def initialize(klass, association, **)
  super(klass)
  @association = association
end

Public Instance Methods

==(other) click to toggle source
# File lib/active_record/association_relation.rb, line 14
def ==(other)
  other == records
end
build(attributes = nil, &block) click to toggle source
# File lib/active_record/association_relation.rb, line 18
def build(attributes = nil, &block)
  block = _deprecated_scope_block("new", &block)
  scoping { @association.build(attributes, &block) }
end
Also aliased as: new
create(attributes = nil, &block) click to toggle source
# File lib/active_record/association_relation.rb, line 24
def create(attributes = nil, &block)
  block = _deprecated_scope_block("create", &block)
  scoping { @association.create(attributes, &block) }
end
create!(attributes = nil, &block) click to toggle source
# File lib/active_record/association_relation.rb, line 29
def create!(attributes = nil, &block)
  block = _deprecated_scope_block("create!", &block)
  scoping { @association.create!(attributes, &block) }
end
new(attributes = nil, &block)
Alias for: build
proxy_association() click to toggle source
# File lib/active_record/association_relation.rb, line 10
def proxy_association
  @association
end

Private Instance Methods

exec_queries() { |record| ... } click to toggle source
Calls superclass method
# File lib/active_record/association_relation.rb, line 35
def exec_queries
  super do |record|
    @association.set_inverse_instance_from_queries(record)
    yield record if block_given?
  end
end