I'm going through the book and everything is going great up until Chapter 7 when I start dealing with the find() funtion. In pages 93-96 you say to replace:
function index() {
$this->Post->recursive = 0;
$this->set('posts', $this->paginate());
}
with this:
function index() {
$this->Post->find('all',array('order'=>'date DESC','limit'=>5,'recursive'=>0));
}
in the posts_controllers.php file. Then to replace the Index action with:
<? foreach($posts as $post): ?>
<div class="story">
<?=$html->link('<h1>'.$post['Post']['name'].'</h1>','/posts/view/'.$post['Post']['id'],null,null,false);?>
<p>Posted<?=date('MjSY,g:ia',strtotime($post['Post']['date']));?></p>
<p>By<?=$post['User']['firstname'];?> <?=$post['User']['lastname'];?> </p>
<br/>
<p><?=$post['Post']['content'];?></p>
</div>
<?endforeach; ?>
Which gives me the following error: Undefined variable: posts [APP/views/posts/index.ctp, line 1]
Looking in the source code you've provided, the index function in the posts_controllers.php file is the same as Chapter 6. Any help?