Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save philsof/4c479e90e6ddc8d2f6fe to your computer and use it in GitHub Desktop.
Save philsof/4c479e90e6ddc8d2f6fe to your computer and use it in GitHub Desktop.
Code review for branch pair-plonsker on active-record-intro-belongs-to-association-challenge

Good effort! Here are my notes on your code:

###Your current associations###

###Your missing associations###

  • Take a look at the schema for this challenge. It contains 4 relationships (each of the three lines is a relationship, and the many-to-many relationship created by the red and green lines combined is also a relationship.) This means you will need to end up with a total of 8 associations on your models (since each relationship requires an association on each end of the relationship). This means you are missing 4 associations.

###Big hints###

  • One-to-many relationships get a has_many on the 'one' side, and a belongs_to on the 'many' side. (Look at the red line in the schema. For that relationship, the has_many goes on the Person model, and the belongs_to goes on the Rating model. This is because each person (aka judge) can have many ratings (since they are rating many dogs).) You will need to set up a total of three of these one-to-many relationships.
  • Many-to-many relationships get a has_many :through on each side of the relationship. You will need one of these relationships, between the Person model and Dog model.

If you get time, revisit this challenge. Any questions let me know.

-Phil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment