Module: Goldiloader::CollectionProxyPatch
- Defined in:
- lib/goldiloader/active_record_patches.rb
Instance Method Summary collapse
-
#exists?(*args, **kwargs) ⇒ Boolean
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.
Instance Method Details
#exists?(*args, **kwargs) ⇒ Boolean
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.
206 207 208 209 210 211 212 213 214 215 |
# 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 |