title: Cakephp Error: Call to a member function find() on a non-object
body: <p>I have the following model:</p>
  
  <pre><code>class Adjustment extends AppModel {
     var $name = 'Adjustment';       
      var $belongsTo = array(
      'Source_Budget'=&gt;array('className'=&gt;'Budget','foreignKey'=&gt;'s_budget_id'),
      'Target_Budget'=&gt;array('className'=&gt;'Budget','foreignKey'=&gt;'t_budget_id'),
      'Source_Project'=&gt;array('className'=&gt;'Project','foreignKey'=&gt;'s_project_id'),
      'Target_Project'=&gt;array('className'=&gt;'Project','foreignKey'=&gt;'t_project_id')
  
    );
  </code></pre>
  
  <p>model budget and project are as below</p>
  
  <pre><code>class Budget extends AppModel {
  var $name='Budget';
  var $belongsTo = array('Year');
  var $hasMany=array('Project','Payment','Revenue',
  'AdjustmentFrom'=&gt;array('className'=&gt;'Adjustment','foreignKey'=&gt;'s_budget_id'),
  'AdjustmentTo'=&gt;array('className'=&gt;'Adjustment','foreignKey'=&gt;'t_budget_id'),
  'TransferFrom'=&gt;array('className'=&gt;'Transfer','foreignKey'=&gt;'s_budget_id'),
  'TransferTo'=&gt;array('className'=&gt;'Transfer','foreignKey'=&gt;'t_budget_id')
   );
  
  class Project extends AppModel {
     var $name = 'Project';
     var $belongsTo = array('Budget','Year');
  
      var $hasMany=array('Payment','Revenue',
  'AdjustmentFrom'=&gt;array('className'=&gt;'Adjustment','foreignKey'=&gt;'s_project_id'),
  'AdjustmentTo'=&gt;array('className'=&gt;'Adjustment','foreignKey'=&gt;'t_project_id'),
  'TransferFrom'=&gt;array('className'=&gt;'Transfer','foreignKey'=&gt;'s_project_id'),
  'TransferTo'=&gt;array('className'=&gt;'Transfer','foreignKey'=&gt;'t_project_id')
    );
  </code></pre>
  
  <p>I have succesfully created a controller with scaffolding which adds/deletes/updates adjustments but when I bake the code I get the message "Error: Call to a member function find() on a non-object " when I try to add an adjustment.</p>
  
  <p>The error is on the following line:</p>
  
  <pre><code>$sourceBudgets = $this-&gt;Adjustment-&gt;SourceBudget-&gt;find('list');
  $targetBudgets = $this-&gt;Adjustment-&gt;TargetBudget-&gt;find('list');
  $sourceProjects = $this-&gt;Adjustment-&gt;SourceProject-&gt;find('list');
  $targetProjects = $this-&gt;Adjustment-&gt;TargetProject-&gt;find('list');
  $this-&gt;set(compact('sBudgets', 'tBudgets', 'sProjects', 'tProjects'));
  </code></pre>
  
  <p>Off cource there is no model SBudget, TBudget, SProject, TProject so I edited the code as below:</p>
  
  <pre><code>   $sourceBudgets = $this-&gt;Adjustment-&gt;Budget-&gt;find('list');
     $targetBudgets = $this-&gt;Adjustment-&gt;Budget-&gt;find('list');
     $sourceProjects = $this-&gt;Adjustment-&gt;Project-&gt;find('list');
     $targetProjects = $this-&gt;Adjustment-&gt;Project-&gt;find('list');
     $this-&gt;set(compact('sBudgets', 'tBudgets', 'sProjects', 'tProjects'));
  </code></pre>
  
  <p>and I added the line
         public $uses = array('Budget', 'Project');</p>
  
  <p>in the Adjustment controller class. Unfortunatly the problem persists and I always get the "Error: Call to a member function find() on a non-object" message.</p>