BrentBarnes / 8-Bit-Flight-Booker

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

Whiteboard Associations #2

Closed BrentBarnes closed 2 years ago

BrentBarnes commented 2 years ago

Is it a has_many through or is it has_many belongs_to?

BrentBarnes commented 2 years ago

First Association draft between Airport and Flight

<> Airport Model airport_code has_many :departing_flights, class_name: "Flight" has_many :arriving_flights, class_name: "Flight"

<> Flight Model departure_airport_id arrival_airport_id start_datetime flight_duration belongs_to :departure_airport, class_name: "Airport" belongs_to :arrival_airport, class_name: "Airport"

BrentBarnes commented 2 years ago

Should make these console commands work

Airport.first.departing_flights Airport.first.arriving_flights

Flight.first.departure_airport Flight.first.arrival_airport