Class: ActiveRecord::AssociationRelation

Inherits:
Relation
  • Object
show all
Defined in:
lib/active_record/association_relation.rb

Constant Summary

Constants inherited from Relation

Relation::CLAUSE_METHODS, Relation::INVALID_METHODS_FOR_DELETE_ALL, Relation::MULTI_VALUE_METHODS, Relation::SINGLE_VALUE_METHODS, Relation::VALUE_METHODS

Constants included from FinderMethods

FinderMethods::ONE_AS_ONE

Constants included from QueryMethods

QueryMethods::FROZEN_EMPTY_ARRAY, QueryMethods::FROZEN_EMPTY_HASH, QueryMethods::VALID_UNSCOPING_VALUES

Constants included from Batches

Batches::ORDER_IGNORE_MESSAGE

Instance Attribute Summary

Attributes inherited from Relation

#klass, #loaded, #predicate_builder, #table

Instance Method Summary collapse

Methods inherited from Relation

#_update_record, #any?, #arel_attribute, #blank?, #cache_key, #delete, #delete_all, #destroy, #destroy_all, #eager_loading?, #empty?, #encode_with, #explain, #find_or_create_by, #find_or_create_by!, #find_or_initialize_by, #first_or_create, #first_or_create!, #first_or_initialize, #initialize_copy, #insert, #inspect, #joined_includes_values, #load, #many?, #none?, #one?, #pretty_print, #records, #reload, #reset, #scope_for_create, #scoping, #size, #substitute_values, #to_a, #to_sql, #update, #update_all, #values, #where_values_hash

Methods included from FinderMethods

#exists?, #fifth, #fifth!, #find, #find_by, #find_by!, #first, #first!, #forty_two, #forty_two!, #fourth, #fourth!, #last, #last!, #raise_record_not_found_exception!, #second, #second!, #second_to_last, #second_to_last!, #take, #take!, #third, #third!, #third_to_last, #third_to_last!

Methods included from Calculations

#average, #calculate, #count, #ids, #maximum, #minimum, #pluck, #sum

Methods included from SpawnMethods

#except, #merge, #merge!, #only, #spawn

Methods included from QueryMethods

#_select!, #arel, #bound_attributes, #create_with, #create_with!, #distinct, #distinct!, #eager_load, #eager_load!, #extending, #extending!, #from, #from!, #get_value, #group, #group!, #having, #having!, #includes, #includes!, #joins, #joins!, #left_outer_joins, #left_outer_joins!, #limit, #limit!, #lock, #lock!, #none, #none!, #offset, #offset!, #or, #or!, #order, #order!, #preload, #preload!, #readonly, #readonly!, #references, #references!, #reorder, #reorder!, #reverse_order, #reverse_order!, #rewhere, #select, #set_value, #unscope, #unscope!, #where, #where!

Methods included from Batches

#find_each, #find_in_batches, #in_batches

Methods included from Explain

#collecting_queries_for_explain, #exec_explain

Methods included from Delegation

#respond_to_missing?

Constructor Details

#initialize(klass, table, predicate_builder, association) ⇒ AssociationRelation

Returns a new instance of AssociationRelation.



3
4
5
6
# File 'lib/active_record/association_relation.rb', line 3

def initialize(klass, table, predicate_builder, association)
  super(klass, table, predicate_builder)
  @association = association
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveRecord::Delegation

Instance Method Details

#==(other) ⇒ Object



12
13
14
# File 'lib/active_record/association_relation.rb', line 12

def ==(other)
  other == records
end

#build(*args, &block) ⇒ Object Also known as: new



16
17
18
# File 'lib/active_record/association_relation.rb', line 16

def build(*args, &block)
  scoping { @association.build(*args, &block) }
end

#create(*args, &block) ⇒ Object



21
22
23
# File 'lib/active_record/association_relation.rb', line 21

def create(*args, &block)
  scoping { @association.create(*args, &block) }
end

#create!(*args, &block) ⇒ Object



25
26
27
# File 'lib/active_record/association_relation.rb', line 25

def create!(*args, &block)
  scoping { @association.create!(*args, &block) }
end

#proxy_associationObject



8
9
10
# File 'lib/active_record/association_relation.rb', line 8

def proxy_association
  @association
end