I have the following Edit method in option controller
public function edit($id = null) {
if (!$this->Option->exists($id)) {
throw new NotFoundException(__('Invalid option'));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->Option->save($this->request->data)) {
$this->Session->setFlash(__('The option has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The option could not be saved. Please, try again.'));
}
} else {
$options = array('conditions' => array('Option.' . $this->Option->primaryKey => $id));
$this->request->data = $this->Option->find('first', $options);
}
}
when i try to access url ( options/edit/1 ) , it throw me an error that Error: The requested address '/cakephp/options/edit/1' was not found on this server.
, and the strange that the index view is working just fine .
I tried to trace the error and i found that the following lines of code is matched
if (!$this->Option->exists($id)) {
throw new NotFoundException(__('Invalid option'));
}
That means that the options.id
is not exist in the database, while the id is exist in the database , i checked many times
Here you can find the full error stack
Invalid option Error: The requested address '/cakephp/options/edit/1' was not found on this server. Stack Trace [internal function] → OptionsController->edit(string) CORE/Cake/Controller/Controller.php line 490 → ReflectionMethod->invokeArgs(OptionsController, array) CORE/Cake/Routing/Dispatcher.php line 191 → Controller->invokeAction(CakeRequest) CORE/Cake/Routing/Dispatcher.php line 165 → Dispatcher->_invoke(OptionsController, CakeRequest) APP/webroot/index.php line 108 → Dispatcher->dispatch(CakeRequest, CakeResponse)
What is the problem here ?
I tried to change the exist
function with the following function ( $this->Option->findAllById($id)
) and it turn that it's working just fine
so the problem seem to be with the exist function ..