It is my understanding that when defining a :counter_cache option it is to be specified on the model that includes the belongs_to declaration. So I am a little unsure of how
I can also confirm that the method outlined by Ivica Lakatos works with Rails 6 for has_many :through relationships using a join model.
belongs_to :physician, counter_cache: :patients_count