method

find_target

Importance_0
v7.1.3.4 - Show latest stable - 0 notes - Class: Association
find_target() private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations/association.rb, line 221
        def find_target
          if violates_strict_loading?
            Base.strict_loading_violation!(owner: owner.class, reflection: reflection)
          end

          scope = self.scope
          return scope.to_a if skip_statement_cache?(scope)

          sc = reflection.association_scope_cache(klass, owner) do |params|
            as = AssociationScope.create { params.bind }
            target_scope.merge!(as.scope(self))
          end

          binds = AssociationScope.get_bind_values(owner, reflection.chain)
          sc.execute(binds, klass.connection) do |record|
            set_inverse_instance(record)
            if owner.strict_loading_n_plus_one_only? && reflection.macro == :has_many
              record.strict_loading!
            else
              record.strict_loading!(false, mode: owner.strict_loading_mode)
            end
          end
        end
Register or log in to add new notes.