Module: Goldiloader::CollectionProxyPatch
- Defined in:
- lib/goldiloader/active_record_patches.rb
Instance Method Summary collapse
-
#exists?(*args) ⇒ 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) ⇒ 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.
170 171 172 173 174 175 176 177 178 179 |
# File 'lib/goldiloader/active_record_patches.rb', line 170 def exists?(*args) # 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? && @association.fully_load? size > 0 else scope.exists?(*args) end end |