我希望能够删除一个用户,但是当我尝试它时会引发以下错误。“错误:在此服务器上找不到请求的地址 '/cakephp/users/delete/8?url=users%2Fdelete%2F8'。”
我的删除功能的代码是
public function delete($id = null)
{
debug($this->User->delete());
if (!$this->request->is('get'))
{
throw new MethodNotAllowedException();
}
if ($this->User->delete($id))
{
$this->Session->setFlash('The user with id: ' . $id . ' has been deleted.');
$this->redirect(array('action' => 'usermanage'));
}
}
[新] 我摆脱了用户管理代码和索引代码,为我的用户模型代码腾出空间..
<?php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
public $primary_key = 'userID';
public $validate = array(
'username' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A username is required'
)
),
'password' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A password is required'
)
),
'name' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'Your name is required'
)
),
'surname' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'Your surname is required'
)
),
'memberType' => array(
'valid' => array(
'rule' => array('inList', array('admin', 'responder', 'volunteer')),
'message' => 'Please enter a valid role',
'allowEmpty' => false
)
),
'address1' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'Please enter your first line of address'
)
),
'address2' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'please enter your second line of address'
)
),
'town' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'Please enter your town'
)
),
'postCode' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'please enter your postcode'
)
),
'dob' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'please enter your date of birth'
)
),
'emailAddress' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'please enter your email address'
)
),
'phoneNumber' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'please enter your phone number'
)
),
'mobileNumber' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'please enter your mobile number'
)
)
);
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
}
}
?>
任何帮助将不胜感激!