Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Portfolio: Blog Comments

exercises/portfolio_comments.livemd

Portfolio: Blog Comments

Mix.install([
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"},
  {:tested_cell, github: "brooklinjazz/tested_cell"},
  {:utils, path: "#{__DIR__}/../utils"}
])

Navigation

Return Home Report An Issue

Blog Comments

You’re going to add a the ability to comment on a blog to your existing portfolio project.

  • Comments belong to a Blog.
  • Blogs have many Comments.

Comments should have :user_id, :content, and :blog_id fields.

classDiagram
  class Comment {
    blog_id: :id
    content: :text
  }

Comment Requirements

Ensure you:

  • Can create an associated comment from the blog show page using a form with a textarea input.
  • List all associated comments on the blog show page.

You do not need to handle commenting on a comment. All comments will be for the associated blog.

Bonus: Usernames

Add a new :username field to each user if you have not already from a previous exercise. Associate comments with the currently signed in user, and display the User’s :username above each comment.

This creates a new relationship between Comments and Users, but does not change the relationship between Comments and Blogs.

  • Users have many Comments.
  • Comments belong to a User.
classDiagram
  class User {
    username: :text
  }
  class Comment {
    user_id: :id
  }

Ensure you:

  • Display the username of the user associated with each comment on the blog show page, in the list of comments.

Commit Your Progress

Run the following in your command line from the beta_curriculum folder to track and save your progress in a Git commit.

$ git add .
$ git commit -m "finish portfolio comments exercise"

Up Next

Previous Next
Book Search Books Book Search Tags