我希望能夠刪除用戶,但是當我嘗試時會引發以下錯誤。 「錯誤:在此服務器上未找到請求的地址'/ 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'));
}
}
[NEW] 我擺脫了usermanagement代碼和索引碼,以騰出空間給我的用戶模式代碼..
<?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']);
}
}
}
?>
任何幫助將不勝感激!
請添加相關路線到您的文章。其他操作是否像編輯和視圖一樣工作? –
編輯功能也不起作用,我爲那個創建了一個問題,但只有不成功的答案:(我現在添加了索引頁面(這導致用戶到用戶管理頁面) – iwj145
'/ cakephp'你文件根目錄? –