1

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.

4

1 回答 1

6

利用

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

在评论模型的顶部。

并开始评论模型如下:

class Comment extends AppModel {

大写字母“A”,而不是小写字母“a”。

于 2013-07-26T02:32:46.200 回答