Sha256: efd4e0cd3670367acbd2bcf3e775a7578b6209cfc6b22cd803d592dade301d43
Contents?: true
Size: 538 Bytes
Versions: 5
Compression:
Stored size: 538 Bytes
Contents
require 'active_record/precount/reflection_checker' module ActiveRecord module Precount module CollectionProxyExtension def count(*args) return super if args.present? counter_name = :"#{@association.reflection.name}_count" if ReflectionChecker.count_loaded?(@association.owner, counter_name) @association.owner.association(counter_name).target else super end end end end Associations::CollectionProxy.prepend(Precount::CollectionProxyExtension) end
Version data entries
5 entries across 5 versions & 1 rubygems