module ActiveRecord::Precount::CollectionProxyExtension

Public Instance Methods

count(*args) click to toggle source
Calls superclass method
# File lib/active_record/precount/collection_proxy_extension.rb, line 6
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