BrentBarnes / 8-Bit-Flight-Booker

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

Set up associations between Airports and Flights #6

Closed BrentBarnes closed 2 years ago

BrentBarnes commented 2 years ago

"Set up associations so you can ask Flight.first.departure_airport, Flight.first.arrival_airport and get back Airport objects. Same for Airport.first.departing_flights and Airport.first.arriving_flights, which should return a list of Flight objects."

BrentBarnes commented 2 years ago
BrentBarnes commented 2 years ago

Working Associations for requirements so far:

<> Airport Model location has_many :departing_flights, class_name: "Flight", foreign_key: :departure_airport_id has_many :arriving_flights, class_name: "Flight", foreign_key: :arrival_airport_id

<> 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

Got it to work with a few hard coded flight items Now to figure out how to seed a bunch of flights