That worked, thank you!
On Oct 29, 11:30 am, Andras Kende <[email protected]> wrote: > Your add function is not closed ... try this: > > <?php > class PostsController extends AppController { > var $name = 'Posts'; > > function index() { > $this->set('posts', $this->Post->find('all')); > > } > > function view($id = null) { > $this->Post->id = $id; > $this->set('post', $this->Post->read()); > > } > > function add() { > if (!empty($this->data)) { > if ($this->Post->save($this->data)) { > $this->Session->setFlash('Your post has been saved.'); > $this->redirect(array('action'=> 'index')); > } > } > > } > > function delete($id) { > $this->Post->delete($id); > $this->Session->setFlash('The post with id: '.$id.' has been > deleted.'); > $this->redirect(array('action'=> 'index')); > > } > } > > ?> > > Andras Kende > > On Oct 29, 2009, at 10:23 AM, artmyth wrote: > > > > > Hi, > > > I just installed cake 1.2.5 - kudos for the easy installation.. > > > I am going through the 1.2 blog > > tutorialhttp://book.cakephp.org/view/219/Blog > > and have run into an error on step 10.1.11 Deleting Posts.. > > > I receive this error when I click on delete: > > > ------ > > Missing Method in PostsController > > > Error: The action delete is not defined in controller PostsController > > > Error: Create PostsController::delete() in file: app/controllers/ > > posts_controller.php. > > > <?php > > class PostsController extends AppController { > > > var $name = 'Posts'; > > > function delete() { > > > } > > > } > > ?> > > -------- > > My posts_controller.php file looks like this: > > > ---- > > <?php > > class PostsController extends AppController { > > var $name = 'Posts'; > > function index() { > > $this->set('posts', $this->Post->find('all')); > > } > > > function view($id = null) { > > $this->Post->id = $id; > > $this->set('post', $this->Post->read()); > > } > > > function add() { > > if (!empty($this->data)) { > > if ($this->Post->save($this->data)) { > > $this->Session->setFlash('Your post has been saved.'); > > $this->redirect(array('action'=> 'index')); > > } > > > function delete($id) { > > $this->Post->delete($id); > > $this->Session->setFlash('The post with id: '.$id.' has been > > deleted.'); > > $this->redirect(array('action'=> 'index')); > > } > > } > > } > > } > > ?> > > ----- > > > So I am hoping I can receive some direction on correcting my code or > > install to proceed with the tutorial. > > > All the best --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
