Module: ActiveRecord::Associations

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Included in:
Base
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/preloader.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/alias_tracker.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/join_dependency.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/preloader/batch.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/collection_proxy.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/preloader/branch.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/association_scope.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/foreign_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/has_one_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/through_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/has_many_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/singular_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/preloader/association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/belongs_to_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/collection_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/join_dependency/join_base.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/join_dependency/join_part.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/has_one_through_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/has_many_through_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/preloader/through_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/disable_joins_association_scope.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/join_dependency/join_association.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/belongs_to_polymorphic_association.rb

Overview

See ActiveRecord::Associations::ClassMethods for documentation.

Defined Under Namespace

Modules: Builder, ClassMethods, ForeignAssociation, ThroughAssociation Classes: AliasTracker, Association, AssociationScope, BelongsToAssociation, BelongsToPolymorphicAssociation, CollectionAssociation, CollectionProxy, DisableJoinsAssociationScope, HasManyAssociation, HasManyThroughAssociation, HasOneAssociation, HasOneThroughAssociation, JoinDependency, Preloader, SingularAssociation

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveSupport::Autoload

autoload, autoload_at, autoload_under, autoloads, eager_autoload, eager_load!, extended

Methods included from ActiveSupport::Concern

append_features, class_methods, extended, included, prepend_features, prepended

Class Method Details

.eager_load!Object



290
291
292
293
294
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 290

def self.eager_load!
  super
  Preloader.eager_load!
  JoinDependency.eager_load!
end

Instance Method Details

#association(name) ⇒ Object

Returns the association instance for the given name, instantiating it if it doesn’t already exist



297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 297

def association(name) # :nodoc:
  association = association_instance_get(name)

  if association.nil?
    unless reflection = self.class._reflect_on_association(name)
      raise AssociationNotFoundError.new(self, name)
    end
    association = reflection.association_class.new(self, reflection)
    association_instance_set(name, association)
  end

  association
end

#association_cached?(name) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


311
312
313
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 311

def association_cached?(name) # :nodoc:
  @association_cache.key?(name)
end

#initialize_dupObject

:nodoc:



315
316
317
318
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations.rb', line 315

def initialize_dup(*) # :nodoc:
  @association_cache = {}
  super
end