class ActiveRecord::Associations::CountLoader

Public Instance Methods

load_target() click to toggle source

Not preloaded behaviour of count_loader association When this method is called, it will be N+1 query

# File lib/active_record/associations/count_loader.rb, line 6
def load_target
  count_target = reflection.name_without_count.to_sym
  @target = owner.association(count_target).count

  loaded! unless loaded?
  target
rescue ActiveRecord::RecordNotFound
  reset
end