CakePHP: COUNT function on a hasmany association

I'm trying to join a model through a hasmany association and then count the number of records. Basically I have users and projects. I want to display the number of associated projects on the user index action. \[code\]var $hasMany = array('Project' => array('className' => 'Project', 'conditions' => '', 'order' => '', 'limit' => '', 'foreignKey' => 'user_id', 'dependent' => true, 'exclusive' => false, 'finderQuery' => '', 'fields' => '', 'offset' => '', 'counterQuery' => '', 'counterCache' => true ) );\[/code\]So I have joined to Project model on user_id and have set the counterCache to true. The question is how do I access this in the user index view?I've tried \[code\]<?php echo $user['Project']['project_count']; ?>\[/code\]and \[code\]<?php echo $user['User']['project_count']; ?>\[/code\]Can someone help me?Jonesy
 
Back
Top