Sha256: cee0ccb899bcec189c7080af8bd144e9bf2586d5b6cdf1c0f5895cd0dbb8808e
Contents?: true
Size: 719 Bytes
Versions: 10
Compression:
Stored size: 719 Bytes
Contents
module ActiveRecord module Associations class CountLoader < SingularAssociation # Not preloaded behaviour of count_loader association # When this method is called, it will be N+1 query def load_target count_target = reflection.name_without_count.to_sym @target = owner.association(count_target).count loaded! unless loaded? target rescue ActiveRecord::RecordNotFound reset end end end module Reflection class CountLoaderReflection < AssociationReflection def initialize(name, scope, options, active_record) super(name, scope, options, active_record) end def macro; :count_loader; end end end end
Version data entries
10 entries across 10 versions & 2 rubygems