Sorry if that summary is a bit convoluted.
Basically, take the following two models:
class One < ActiveRecord::Base
belongs_to :two, :counter_cache => true
end
class Two < ActiveRecord::Base
has_many :ones
end
OK, the belongs_to in One requires the table 'twos' to have the column 'ones_count'. However, the problem is that the has_many associations also gives Two a ones_count method! The method is always called and the attribute is never used resulting in unnecessary DB calls.
Two solutions that I can see. One requires core changes and the other database changes.
Core solution:
Have the *_count method look for the attribute *_count before going to the database
Database solution:
Instead of <table_name>_count, use <singular>_count and give the custom column name to :counter_cache (in place of true). Then, use <singular>_count in your code to get the cached count and the <table_name>_count to go to the database.
The database solution is more a workaround... the core solution seems like it should be a relatively easy fix though I'm unfamiliar with the core code.