Search code examples
cakephpcontainable

Cakephp and Containable error


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?


Solution

  • 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();