Hbtm cache counter?

Can I use the cache counter with respect to habtm in rails 3?

I really need to speed up my application.

+8
ruby-on-rails ruby-on-rails-3
source share
3 answers

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 .

Or use has_many :throught instead of the HABTM association. I never use HABTM because it looks uncomfortable for me.

Related topic:

counter_cache with has_many: through

+3
source share

In rails 4, counter_cache for the has_and_belongs_to_many relationship has_and_belongs_to_many fine.

+3
source share

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 :)

+2
source share

All Articles