method
find_target
rails latest stable - Class:
ActiveRecord::Associations::Association
find_target()private
No documentation available.
# 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