0
votes

I have the containable behavior in my appModel. When I do this in my Asset model:

$this->Asset->contain();
$this->find.....

I'm getting the following error: Fatal error: Call to a member function contain() on a non-object

However, when I use contain like this it works fine:

$this->find('all', array('conditions'=>array('Asset.name ='=>'goodAsset'), 'contain'=>false) );

Any ideas?

1
Check that the model really has the containable behaviour with debug($this->Asset->actsAs). - Joni
no need to call $this->contain(); and set 'contain' => false, they both do the same thing. - dogmatic69

1 Answers

2
votes

You use $this->Model->method() only in controllers. In the model drop the model object from between (because $this already points to it):

$this->contain();