Sha256: 4df238e20c9fc02f8826660e8d8a321d2200d342c09f871fc2f2f56a1ee10acf
Contents?: true
Size: 548 Bytes
Versions: 1
Compression:
Stored size: 548 Bytes
Contents
module ActiveRecord module Precount module CollectionProxyExtension def count(*args) return super(*args) if args.present? counter_name = :"#{@association.reflection.name}_count" owner = @association.owner if owner.class.has_reflection?(counter_name) && owner.association(counter_name).loaded? owner.association(counter_name).target else super(*args) end end end end Associations::CollectionProxy.prepend(Precount::CollectionProxyExtension) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-precount-0.6.0 | lib/active_record/precount/collection_proxy_extension.rb |