I’m writing a plugin using Cake/2.5.5 and I want to insert sample data. For that, I’m writing a method in my custom FooManagerSchema
class that extends CakeSchema
, which I execute from shell:
Console\cake schema create --plugin FooManager --path /path/to/Config/Schema --file sample_data.php
I can successfully retrieve existing data this way:
/* @var $vehicleModel Vehicle */
$vehicleModel = ClassRegistry::init('Vehicle');
debug($vehicleModel->find('all'));
However, I can’t manage to obtain associated records:
/* @var $vehicleModel Vehicle */
$vehicleModel = ClassRegistry::init('Vehicle');
debug($vehicleModel->find('all', array(
'contain' => array('Person')
)));
… triggers this:
Warning Error: Model “Vehicle” is not associated with model “Person”
… and results lack the Person
arrays, even though a fairly similar code works fine in VehiclesController
:
debug($this->Vehicle->find('all', array(
'contain' => array('Person'),
)));
… what means that model associations are correct.
What am I missing?