This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# PreloadCounts | |
# | |
# Usage: | |
# collection = Post.limit(10).preload_counts(:users) | |
# collection.first.users.count # fires one query to fetch all counts | |
# collection[1].users.count # uses the cached value | |
# collection.last.users.count # uses the cached value | |
# | |
# Call `::PreloadCounts.enable!` inside of an initializer to enable preloading of association counts |