This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/workshop/controllers/posts_controller.php b/workshop/controllers/posts_controller.php | |
index 35c892c..d2324d4 100644 | |
--- a/workshop/controllers/posts_controller.php | |
+++ b/workshop/controllers/posts_controller.php | |
@@ -28,7 +28,7 @@ class PostsController extends AppController { | |
} | |
} | |
$tags = $this->Post->Tag->find('list'); | |
- $users = $this->Post->User->find('list'); | |
+ $users = $this->Post->User->find('list', array('fields' => array('id', 'username'))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/workshop/views/posts/view.ctp b/workshop/views/posts/view.ctp | |
index df8a9dc..f5df297 100644 | |
--- a/workshop/views/posts/view.ctp | |
+++ b/workshop/views/posts/view.ctp | |
@@ -8,7 +8,7 @@ | |
</dd> | |
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('User'); ?></dt> | |
<dd<?php if ($i++ % 2 == 0) echo $class;?>> | |
- <?php echo $html->link($post['User']['id'], array('controller' => 'users', 'action' => 'view', $post['User']['id'])); ?> | |
+ <?php echo $html->link($post['User']['username'], array('controller' => 'users', 'action' => 'view', $post['User']['id'])); ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/workshop/views/posts/index.ctp b/workshop/views/posts/index.ctp | |
index 7892034..ed19d04 100644 | |
--- a/workshop/views/posts/index.ctp | |
+++ b/workshop/views/posts/index.ctp | |
@@ -29,7 +29,7 @@ foreach ($posts as $post): | |
<?php echo $post['Post']['id']; ?> | |
</td> | |
<td> | |
- <?php echo $html->link($post['User']['id'], array('controller' => 'users', 'action' => 'view', $post['User']['id'])); ?> | |
+ <?php echo $html->link($post['User']['username'], array('controller' => 'users', 'action' => 'view', $post['User']['id'])); ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/workshop/config/routes.php b/workshop/config/routes.php | |
index 2858312..6c56a03 100755 | |
--- a/workshop/config/routes.php | |
+++ b/workshop/config/routes.php | |
@@ -30,7 +30,8 @@ | |
* its action called 'display', and we pass a param to select the view file | |
* to use (in this case, /app/views/pages/home.ctp)... | |
*/ | |
- Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); | |
+ //Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="posts form"> | |
<?php echo $form->create('Post');?> | |
<fieldset> | |
<legend><?php __('Edit Post');?></legend> | |
<?php | |
echo $form->input('id'); | |
echo $form->input('user_id'); | |
echo $form->input('title'); | |
echo $form->input('body'); | |
echo $form->input('Tag'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PostsController extends AppController { | |
var $name = 'Posts'; | |
var $helpers = array('Html', 'Form'); | |
function index() { | |
$this->Post->recursive = 0; | |
$this->set('posts', $this->paginate()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Post extends AppModel { | |
var $name = 'Post'; | |
var $validate = array( | |
'user_id' => array('numeric'), | |
'title' => array('notempty') | |
); | |
//The Associations below have been created with all possible keys, those that are not needed can be removed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Tag extends AppModel { | |
var $name = 'Tag'; | |
var $validate = array( | |
'name' => array('notempty') | |
); | |
//The Associations below have been created with all possible keys, those that are not needed can be removed | |
var $hasAndBelongsToMany = array( |