好的,这真的很奇怪,我有以下 test_sign_up 操作:
public function test_sign_up(){
if($this->request->is('post')){
$signup_result = $this->request->data;
$userData = array('User' => array(
'username' =>$signup_result['User']['username'],
'password'=> $signup_result['User']['password'],
'group_id' => 2,
'client_id' => 9999));
$this->User->create();
if ($this->User->saveAll($userData)) {
$this->Session->setFlash(__('The user has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
}
现在,当我尝试保存用户时,我得到:
Call to a member function create() on a non-object
请注意,此功能在我的UsersController
更新
如果我做:
$this->loadModel('User');
它没有问题,但是当我已经在绑定到用户模型的控制器中时是否有必要这样做?