Skip to content

Commit

Permalink
Using mapResources for our API
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Sep 2, 2011
1 parent 330fa68 commit b87eee4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Config/routes.php
Expand Up @@ -22,6 +22,7 @@
*/

Router::parseExtensions('json');
Router::mapResources('Courses');
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
Expand Down
6 changes: 3 additions & 3 deletions Controller/CoursesController.php
Expand Up @@ -7,7 +7,7 @@
class CoursesController extends AppController {

public function beforeFilter() {
$this->Auth->allow('index', 'view', 'add');
$this->Auth->allow('index', 'view');
}

/**
Expand Down Expand Up @@ -68,10 +68,10 @@ public function edit($id = null) {
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->Course->save($this->request->data)) {
$this->Session->setFlash(__('The course has been saved'));
$this->Session->setFlash(__('The course has been saved'), 'success');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The course could not be saved. Please, try again.'));
$this->Session->setFlash(__('The course could not be saved. Please, try again.'), 'error');
}
} else {
$this->request->data = $this->Course->read(null, $id);
Expand Down
4 changes: 2 additions & 2 deletions View/Layouts/json/default.ctp
Expand Up @@ -2,8 +2,8 @@
$status = 'success';
$message = '';
if ($this->Session->check('Message.flash')) {
$status = $this->Session->read('Message.element');
$message = $this->Session->read('Message.message');
$status = $this->Session->read('Message.flash.element');
$message = $this->Session->read('Message.flash.message');
$this->Session->flash();
}
$errors = array();
Expand Down

0 comments on commit b87eee4

Please sign in to comment.