module Goldiloader::CollectionProxyPatch
Public Instance Methods
exists?(*args, **kwargs)
click to toggle source
The CollectionProxy just forwards exists? to the underlying scope so we need to intercept this and force it to use size which handles fully_load properly.
# File lib/goldiloader/active_record_patches.rb, line 206 def exists?(*args, **kwargs) # We don't fully_load the association when arguments are passed to exists? since Rails always # pushes this query into the database without any caching (and it likely not a common # scenario worth optimizing). if args.empty? && kwargs.empty? && @association.fully_load? size > 0 else scope.exists?(*args, **kwargs) end end