Challenge 1: Wire Up Post and Comment — Solution # app/models/post.rb class Post < ApplicationRecord has_many :comments end # app/models/comment.rb class Comment < ApplicationRecord belongs_to :post end # Demonstrating each direction: @post.comments # => all Comment records where post_id = @post.id @comment.post # => the single Post this comment belongs to =begin Notes: - has_many :comments on Post and belongs_to :post on Comment are two halves of the same relationship -- both are needed for both directions (@post.comments and @comment.post) to work. - This relies entirely on the post_id column already created by Chapter 5's migration; belongs_to :post specifically expects a column named post_id (the singular association name + _id) by convention, with no extra configuration needed since the column already matches. - @post.comments returns a chainable relation (per Chapter 5), not a plain array -- you could continue with @post.comments.where(...) or @post.comments.order(...) exactly as shown in the chapter. =end