Can I use the cache counter with respect to habtm in rails 3?
I really need to speed up my application.
There is no built-in method for HABTM , but just create your own cache counter (in fact, I did this many times before I invented counter_cache .
HABTM
counter_cache
Or use has_many :throught instead of the HABTM association. I never use HABTM because it looks uncomfortable for me.
has_many :throught
Related topic:
counter_cache with has_many: through
In rails 4, counter_cache for the has_and_belongs_to_many relationship has_and_belongs_to_many fine.
has_and_belongs_to_many
For what it's worth, I created a version for HABTM that you can see here .
If you have any questions / comments / suggestions, feel free to leave them - or even a plug and let me see :)