Skip to content

Instantly share code, notes, and snippets.

@slywalker
Created March 11, 2010 02:38
Show Gist options
  • Save slywalker/328749 to your computer and use it in GitHub Desktop.
Save slywalker/328749 to your computer and use it in GitHub Desktop.
diff --git a/workshop/controllers/posts_controller.php b/workshop/controllers/posts_controller.php
index 35c892c..6a2d1e2 100644
--- a/workshop/controllers/posts_controller.php
+++ b/workshop/controllers/posts_controller.php
@@ -5,7 +5,11 @@ class PostsController extends AppController {
var $helpers = array('Html', 'Form');
function index() {
- $this->Post->recursive = 0;
+ $this->paginate = array(
+ 'contain' => array(
+ 'User' => array('fields' => array('id', 'username')),
+ ),
+ );
$this->set('posts', $this->paginate());
}
@@ -14,6 +18,10 @@ class PostsController extends AppController {
$this->Session->setFlash(__('Invalid Post', true));
$this->redirect(array('action' => 'index'));
}
+ $this->Post->contain(array(
+ 'User' => array('fields' => array('id', 'username')),
+ 'Tag',
+ ));
$this->set('post', $this->Post->read(null, $id));
}
@@ -46,6 +54,10 @@ class PostsController extends AppController {
}
}
if (empty($this->data)) {
+ $this->Post->contain(array(
+ 'User' => array('fields' => array('id', 'username')),
+ 'Tag',
+ ));
$this->data = $this->Post->read(null, $id);
}
$tags = $this->Post->Tag->find('list');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment