title: CakePHP find on a join table
body: <p>Sorry if this is obvious - I'm trying to do a find() on a join table and failing, whats the correct syntax to do this?</p>
  
  <p>Basically I have expenseCode table with a HABTM releationship with the expense table.</p>
  
  <p>In my expenseCode model I have:</p>
  
  <pre><code>public function beforeDelete($cascade  = false) {
  
      $count = $this-&gt;Expense-&gt;find("count", array(
          'conditions' =&gt; array('expense_code_id' =&gt; $this-&gt;id)
      ));
  
      if ($count == 0) {
          return true;
      } else {
          //$this-&gt;Session-&gt;setFlash('Record cannot be deleted as it has ' . $count . 'number of expenses attached to it');
          return false;
      }
  
  }
  </code></pre>
  
  <p>If I uncomment the setFlash() I get the error.</p>
  
  <p>Where am I going wrong? Thanks in advance.</p>