I'm having a bit of trouble getting a page to redirect after deleting some data. It previously worked, and I have since added a lot so I have no idea what's causing the issue.
Here's the function, generated through Baking. The strange part is the function works and properly deletes the record, but it just stays on the blank page.
public function delete($id = null) {
$this->Visit->id = $id;
if (!$this->Visit->exists()) {
throw new NotFoundException(__('Invalid visit'));
}
$this->request->onlyAllow('post', 'delete');
if ($this->Visit->delete()) {
$this->Session->setFlash(__('Visit deleted'));
$this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__('Visit was not deleted'));
$this->redirect(array('action' => 'index'));
}
However, when I change it to just redirect upon the function call, it works. Something is up with the delete and I can't seem to figure out what's happening.
public function delete($id = null) {
$this->Visit->id = $id;
if (!$this->Visit->exists()) {
throw new NotFoundException(__('Invalid visit'));
}
$this->Session->setFlash(__('Visit deleted'));
$this->redirect(array('action' => 'index'));
}
What can I look for? I don't have anything in my Models regarding redirects