Module: ActiveRecord::Associations
- Extended by:
- ActiveSupport::Concern
- Defined in:
- activerecord/lib/active_record/associations.rb,
activerecord/lib/active_record/associations/preloader.rb,
activerecord/lib/active_record/associations/association.rb,
activerecord/lib/active_record/associations/join_helper.rb,
activerecord/lib/active_record/associations/alias_tracker.rb,
activerecord/lib/active_record/associations/join_dependency.rb,
activerecord/lib/active_record/associations/collection_proxy.rb,
activerecord/lib/active_record/associations/preloader/has_one.rb,
activerecord/lib/active_record/associations/association_scope.rb,
activerecord/lib/active_record/associations/preloader/has_many.rb,
activerecord/lib/active_record/associations/has_one_association.rb,
activerecord/lib/active_record/associations/through_association.rb,
activerecord/lib/active_record/associations/singular_association.rb,
activerecord/lib/active_record/associations/preloader/belongs_to.rb,
activerecord/lib/active_record/associations/has_many_association.rb,
activerecord/lib/active_record/associations/preloader/association.rb,
activerecord/lib/active_record/associations/belongs_to_association.rb,
activerecord/lib/active_record/associations/collection_association.rb,
activerecord/lib/active_record/associations/preloader/has_one_through.rb,
activerecord/lib/active_record/associations/join_dependency/join_base.rb,
activerecord/lib/active_record/associations/join_dependency/join_part.rb,
activerecord/lib/active_record/associations/preloader/has_many_through.rb,
activerecord/lib/active_record/associations/has_one_through_association.rb,
activerecord/lib/active_record/associations/has_many_through_association.rb,
activerecord/lib/active_record/associations/preloader/through_association.rb,
activerecord/lib/active_record/associations/preloader/singular_association.rb,
activerecord/lib/active_record/associations/preloader/collection_association.rb,
activerecord/lib/active_record/associations/join_dependency/join_association.rb,
activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb,
activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb,
activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
Overview
Active Record Has And Belongs To Many Association
Defined Under Namespace
Modules: Builder, ClassMethods, JoinHelper, ThroughAssociation Classes: AliasTracker, Association, AssociationScope, BelongsToAssociation, BelongsToPolymorphicAssociation, CollectionAssociation, CollectionProxy, HasAndBelongsToManyAssociation, HasManyAssociation, HasManyThroughAssociation, HasOneAssociation, HasOneThroughAssociation, JoinDependency, Preloader, SingularAssociation
Constant Summary collapse
- AssociationCollection =
ActiveSupport::Deprecation::DeprecatedConstantProxy.new( 'ActiveRecord::Associations::AssociationCollection', 'ActiveRecord::Associations::CollectionProxy' )
Instance Attribute Summary collapse
-
#association_cache ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#association(name) ⇒ Object
Returns the association instance for the given name, instantiating it if it doesn’t already exist.
-
#clear_association_cache ⇒ Object
Clears out the association cache.
Methods included from ActiveSupport::Concern
append_features, extended, included
Instance Attribute Details
#association_cache ⇒ Object (readonly)
:nodoc:
151 152 153 |
# File 'activerecord/lib/active_record/associations.rb', line 151 def association_cache @association_cache end |
Instance Method Details
#association(name) ⇒ Object
Returns the association instance for the given name, instantiating it if it doesn’t already exist
154 155 156 157 158 159 160 161 162 163 164 |
# File 'activerecord/lib/active_record/associations.rb', line 154 def association(name) #:nodoc: association = association_instance_get(name) if association.nil? reflection = self.class.reflect_on_association(name) association = reflection.association_class.new(self, reflection) association_instance_set(name, association) end association end |
#clear_association_cache ⇒ Object
Clears out the association cache.
146 147 148 |
# File 'activerecord/lib/active_record/associations.rb', line 146 def clear_association_cache #:nodoc: @association_cache.clear if persisted? end |