1. 1

  2. 1

    The only ActiveRecord feature that is more of a footgun than this is default_scope. Almost every time I have ever used counter caches I’ve ended up having to replace the functionality with my own implementation.

    1. 1

      Hmmm. Is that because the cache doesn’t serve your needs, because it becomes inaccurate, or because of performance concerns (or for some other reason)?

      1. 2

        In my experience, a simple count of all associations is rarely what you actually need, especially if you’re soft-deleting records. Counts more often than not need to take some kind of business logic into account when being computed, and this is not possible with this feature.

        Accuracy is also, less frequently, a problem as well.