Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counter cache on a habtm relation?

Is it possible to use counter cache on a habtm relation in rails 3 ?

I really need it to speed up my application.

like image 239
Linus Oleander Avatar asked Apr 19 '11 18:04

Linus Oleander


1 Answers

There is no built in method for HABTM but it is simple to make your own counter cache (actually I was doing it many times before I've invented counter_cache.

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

Related topic:

counter_cache with has_many :through

like image 92
fl00r Avatar answered Sep 29 '22 12:09

fl00r