Cakephp belongs to relation - access to related model
I have a consultants table with a "specialty_id" foreign key that is associated with the "specilaties" table.
class Consultant extends AppModel {
public $belongsTo = array(
'Specialty' => array(
'className' => 'Specialty',
'conditions' => array('Specialty.active' => 1)
)
);
}
class Specialty extends AppModel {
public $hasOne = 'Consultant';
}
I think this is correct, however I cannot get the list of specialties from the consultant controller ("Calling member function () for non-object")
$this->set('specialties', $this->Specialty->find('all'));
Where am I going wrong?
thank
+3
source to share
2 answers