Fix for #80165018. Added counter_cache to associates model. This will prevent select count(*) queries on associated tables as the count of associated records will be cached by rails.