0
votes

I'm currently migrating a working app from CakePHP 1.2 to 1.3. Most things seem fine so far, except it appears that some models are not being loaded correctly in the app_controller.php. For example I have included the model 'message_thread.php' with

var $uses = array('MessageThread');

but when I try and

debug($this->MessageThread);

I get the error

Notice (8): Undefined property: ProjectsController::$MessageThread [APP/app_controller.php, line 415]

The model is also loaded in the Projects controller, but I don't see why this is being called on a simple debug($this->MessageThread); call.

This problem has broken previously working code, so that

$this->MessageThread->create();

result in the following error

Fatal error: Call to a member function create() on a non-object in

any ideas?

1
I had similar issues in 1.3 when also declaring $uses in both AppModel and ConcreteModel. - sibidiba
@sibidiba : $uses array has to be used in controller . - RSK
Yeah, try adding $uses in your controller, not in AppController. - metrobalderas
using '$uses' array is not a good practice.Always use relation or loadModel for it. - RSK

1 Answers

1
votes

You can load models into all controllers in the app controller as you are trying. Are you using php5? If so, tru using public instead of var when defining the array to see if the array is I heartier properly.

public $uses = array('MessageThread');

As per the other comments, it is best if you load models in each specific controller. Please let me know if this works.