Marc
Marc

Reputation: 493

Access to another model throws error Cakephp

so i have the following controller:

    class ForwardsController extends AppController
{
    public $uses = array('Offer', 'ExceptionUrl', 'Forward', 'Brand', 'MyModel, Website');
    public $components = array('RequestHandler', 'HasOffers', 'BloglicHelper', 'Paginator', /*'DebugKit.Toolbar'*/);
    public $categories = array();
    public $helpers = array('Js' => array('Jquery'), 'Paginator');

    public function beforeFilter()
    {
        parent::beforeFilter();
    }

}

Now when i try to do the following:

     $web = $this->Website->find('all');

i get the following error:

2013-09-09 10:08:14 Error: Fatal Error (1): Call to a member function find() on a non-object

Upvotes: 0

Views: 39

Answers (1)

lukasz
lukasz

Reputation: 339

You have to load the Website model before find.

$this->loadModel('Website'); // add this line
$web = $this->Website->find('all');

Upvotes: 1

Related Questions