Session 11: Exercises

Exercise 1:


  • Create a User model. Users have a name.

  • Create a Comment model. Comments have a body and user_id corresponding to the user who made the comment. Comments belong_to users.

Exercise 2:


  • Implement a page which lists all of the comments that have been made along with the name of the user who made the comment.

Exercise 3:


  • Create a form where someone can type in their name. When submitting, create a User object with the given name and store the ID of the user object on the session.

  • Create a method on ApplicationController which allows retrieving the current_user

Exercise 4:


  • Implement a form which takes in the body of a Comment and puts it in the database along with the ID of the current user.