How to add counter cache with custom column in Rails?

This article explains how to add counter cache with a custom column in Rails.