I want to display the total number of comments for a particular post in my blog. I have 'posts' and 'comments' tables in my database. Now, I am a bit confused about using counterCache. I first created a field in the 'posts database', namely, 'comment_count' and then I added the counterCache key in the post model.
var $hasMany = array('Comment'=>array('counterCache'=>true));
But this was not working. I also tried to go the other way round, i.e by creating a field in the cooments table and the adding the counterCache key to the model. But this was also not working. What am I missing here??Can I display the number of comments using find('count')?? or is there any other way to achieve this?