Hey,
For comments, it's pretty similar to the post model. You'll probably want to add a relationship between the post and comments. In the post model you should have:
var $has_many = 'comments';
and the comment model should have:
var $belongs_to = 'post';
along with a field in the comment table named post_id. Note that models can be separated with comas in the string.
As for the user model, there is a rails tutorial that you can try to implement (that I based my user model off of). You can also implement similar relationship as with comments and posts.
You'll probably want a 'password confirm' field when users register. The to do this, you have manually set password + password_confirmation fields in your controller when the user submits the forum (assuming the password fields don't exist):
$this->user->set('password', $this->params['user']['password']);
$this->user->set('password_repeat', $this->params['user']['password_confirmation']);
This allows you to use getters/setters for these imaginary properties like so:
function setPassword($value){
$this->password = $value;
$this->password_hash = sha1($value);
}
function setPassword_confirmation($value){
$this->password_confirmation = $value;
}
bermi explained the getters/setters in more detail.
As for user logins/logouts you can just use the session and store the user's id, and username. To validate to see if the user is logged in, just check the session data. It's best to put this method in your application_controller.php (in your apps folder). Then in your controllers, you can just call that method.
For the model end of user authentication, you should also probably make a function that validates the username + password when the user tries to logged in.
I think that's a good summary. :)
don't forget the next line in post_controller.php
var $models = 'post, comment';
apparently missing in the screen cast.
1 to 4 of 4