I'm new to CakePHP
and just want to display a list of associated tags in a post's view.
I have searched all over the web and nothing seems to work.
This is what I have at the moment:
// PostController
public function view($id = null) {
$this->set('tags', $this->Post->Tag->find('all', array('conditions' => array('PostTag.post_id' => $id))));
if (!$id) {
throw new NotFoundException(__('Invalid post'));
}
$post = $this->Post->findById($id);
if (!$post) {
throw new NotFoundException(__('Invalid post'));
}
$this->set('post', $post);
}
// Post's view.ctp
echo $this->Text->toList($tags);
This is the error I'm getting:
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'PostTag.post_id' in 'where clause'
This should be so easy but I am completely stuck.
Thanks to anyone who can help!