BrentBarnes / 8-Bit-Flight-Booker

A Ruby-on-Rails app where users can book flights for multiple passengers
0 stars 0 forks source link

3. Set up associations between bookings, passengers, and flights #20

Closed BrentBarnes closed 2 years ago

BrentBarnes commented 2 years ago

Set up associations between Bookings, Passengers, and Flights.

BrentBarnes commented 2 years ago

First draft associations!

-Booking belongs_to :flight has_many :passengers

-Passenger belongs_to :flight belongs_to :booking

-Flight has_many :bookings has_many :passengers

BrentBarnes commented 2 years ago

Should Flight's associations be something like this instead?

has_many :passengers, through: :bookings ???

edit: Don't think this is necessary as all below associations work

BrentBarnes commented 2 years ago

Should be able to run these queries: