TL; DR / Answer:
You can either fix the association or load the model and delete the end-to-end call (part ->Chantier :
$this->loadModel('Program'); $programs = $this->Program->find('list');
Details / Explanation:
This error basically means that you are trying to call find() on a model that is not loaded into the controller.
By default, the controller model is loaded. And, as you do this, you can use the THROUGH model for a loaded model. (if associations are configured correctly).
For instance:
//ChantiersController $this->Pizza->find('all'); //ERROR - Pizza model isn't loaded
To solve this problem, just load the model before trying it:
$this->loadModel("Pizza"); $this->Pizza->find('all');
In your case, since it looks like you are using associations with the Chantier model to search through other models, the relationship between the two models is probably incorrect.
source share