I’ve a set of two models in habtm relationship. However,
since :counter_cache can only be used on belongs_to method, how can I
implement the counter cache on habtm models?
I have tried with after_add and after_remove callbacks, but I don’t
know quite how to code the method for updating.
I created this method:
self.posts_count = self.posts.length
class Category < ActiveRecord::Base
:after_add => :update_count,
:after_remove => :update_count
However, the method doesn’t work (or I wouldn’t be posting here, would
I?)… I would appreciate any help, or maybe a tip on where to find