Luke16
Luke16

Reputation: 13

CakePHP Error: Class 'appModel' not found

I have been working on the same CakePHP application for several months (no version migrations) and have recently run into an error that I can't seem to find any reason for its cause. The error message says it comes from line 4 of this file (Comment.php)

class Comment extends appModel {

var $actsAs = array(
    'Containable'
);

var $belongsTo = 'Core';

public $validate = array(
    'author'    => array(
        'rule'=>'notEmpty'
    ),
    'body'  => array(
        'rule'=>'notEmpty',
        'message' => 'You cannot leave a blank comment'
    )
);
}

This comes up only when attempting to load the model:

Controller::loadModel('Comment');

For some context, each Core model relates to a form which can be commented on. The comments are related to the Core model via foreign key relation core_id. Each Core relates to only a single form and can have any number of comments.

The only other solutions to similar problems I can find were caused by migrating from one version of cake to another but I have been using the same version since beginning the project.

Upvotes: 1

Views: 5845

Answers (1)

Tahmina Khatoon
Tahmina Khatoon

Reputation: 1091

Use

App::uses('AppModel', 'Model');

at the top of the comment model.

and start comment model as follows:

class Comment extends AppModel {

Capital 'A', not small 'a'.

Upvotes: 6

Related Questions