cache_counter for habtm

Posted by piemesons on Stack Overflow See other posts from Stack Overflow or by piemesons
Published on 2010-06-17T09:49:24Z Indexed on 2010/06/17 9:53 UTC
Read the original article Hit count: 179

Hello How can use cache_counter in a habtm. For example a question has many tags and a tag can belong to many questions.

 question habtm tags

Now i want to find out number of questions belonging to every tag. One way is counting everytime.

But, in case of one_to_many i done same thing in this way.

Like one question has many answers. then in answer model i specified

     belongs_to :question,:cache_counter=>true

It solved my problem. So how to do the same in habtm.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about entity-relationship