Class: ActiveRecord::Associations::CountLoader
- Inherits:
-
SingularAssociation
- Object
- SingularAssociation
- ActiveRecord::Associations::CountLoader
- Defined in:
- lib/active_record/precount/reflection_extension.rb
Instance Method Summary collapse
-
#load_target ⇒ Object
Not preloaded behaviour of count_loader association When this method is called, it will be N+1 query.
Instance Method Details
#load_target ⇒ Object
Not preloaded behaviour of count_loader association When this method is called, it will be N+1 query
6 7 8 9 10 11 12 13 14 |
# File 'lib/active_record/precount/reflection_extension.rb', line 6 def load_target count_target = reflection.name.to_s.sub(/_count\z/, '').to_sym @target = owner.association(count_target).size loaded! unless loaded? target rescue ActiveRecord::RecordNotFound reset end |