Many-to-many Relationships in Ruby

Thanks for stopping by! Be sure to check out my other work on Linkedin and Github.

Image for post
Image for post
Photo from http://ilmfruits.com/

Setting up our classes:

Feel free to skip to “accessing information..” if you already have a good grasp on setting up classes.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Accessing information within the Coven class, from Coven:

Testing a variable we created

Image for post
Image for post
Image for post
Image for post

Accessing information within the BloodOath (joiner) class, from Coven:

To find information from our joiner class from coven, we will define an instance method. In this case, let’s find all of the blood_oaths (BloodOath instances) that a specific instance of coven has. (Reminder that these two methods are the same).

Image for post
Image for post
Image for post
Image for post

Accessing information within the Witch class, from Coven:

The deliverables that require the ‘bridge’ or joiner are definitely tricky when you first start out, but you will have clarity in time!!

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Written by

Austin, Texas — Software Engineering Student at Flatiron.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store