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

Blog: Cover Image

exercises/blog_cover_image.livemd

Blog: Cover Image

Mix.install([
  {:jason, "~> 1.4"},
  {:kino, "~> 0.9", override: true},
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"}
])

Navigation

Home Report An Issue One-to-One RelationshipsTailwind

Blog: Cover Image

You’re going to add a cover images in your blog project.

Each Post will have a one-to-one relationship with a CoverImage.

erDiagram

Post {
}

CoverImage {
    string url
    id post_id
}

Post ||--O| CoverImage: "has one/belongs to"

Requirements

  • Migration and Schema:
    • Create cover_images table with a url and a post_id foreign key field.
    • Associate the Post and CoverImage records through a has_one/belongs_to association.
  • Functionality
    • Create, update, and delete posts with cover images using a url.
    • Display the post cover image on the post show page.
  • Tests
    • Write context and controller tests to ensure a user can create, update, and delete a post with a cover image.
    • All tests should pass. You may need to modify old tests and pages to ensure they continue to pass.

Commit Your Progress

DockYard Academy now recommends you use the latest Release rather than forking or cloning our repository.

Run git status to ensure there are no undesirable changes. Then run the following in your command line from the curriculum folder to commit your progress.

$ git add .
$ git commit -m "finish Blog: Cover Image exercise"
$ git push

We’re proud to offer our open-source curriculum free of charge for anyone to learn from at their own pace.

We also offer a paid course where you can learn from an instructor alongside a cohort of your peers. We will accept applications for the June-August 2023 cohort soon.

Navigation

Home Report An Issue One-to-One RelationshipsTailwind