Ruby Objects Belong To Lab

Objectives

  • Write classes that are related via the "belongs to" relationship.

Instructions

In this lab, you'll be coding a Song and Artist class. A song should belong to an artist. You'll also be coding a Post and Author class. A post should belong to an author.

  • Artists should have a name.
  • Songs should have a title and belong to an artist. A song should be able to tell you the name of its artist:
song.artist.name
  # => "Beyonce"
  • Posts should have a title and belong to an author. A post should be able to tell you the name of its author:
post.author.name
  # => "Hillary"

View Ruby Objects Belong To Lab on Learn.co and start learning to code for free.