Airport and Flight classes.Airport and Flight objects.Flight object, using getter and setter methods to manage it association links.Airport object along with its associated Flight objects.Reset and reseed the database:
rails db:migrate:reset && rails db:seedCreate “arrival” association:
Airport and Flight classes as per the class diagram below (see label Ⓐ).Airport class definition with the new has_many declaration visible.Flight class definition with the new belongs_to declaration visible.Seed database with association links:
seeds.rb script to seed the database with new association links as per the object diagram below (see labels Ⓐ Ⓑ Ⓒ).seeds.rb file with code creating the new association links visible.Flight.all with foreign key values for the new links visible.Create a new Flight and link it to departure and arrival airports:
Airport objects:
lax.atl.Flight object (unsaved), which will represent a flight from LAX to ATL, as follows:
07-21-2028 11:05:00 AM07-21-2028 01:35:00 PMlax_atl.lax_atl variable, set the flight’s association links as follows:
departure_airport references the LAX Airport object.arrival_airport references the ATL Airport object.lax_atl variable, save the new Flight object and its association links to the database.lax_atl.departure_airport and lax_atl.arrival_airport with the resultant Airport object output visible.Delete a parent Airport object along with all its child Flight objects:
Airport object, storing a reference to it in variable mem.mem variable, destroy the MEM Airport object.
Flight objects with MEM as their departure or arrival airports should be automatically deleted (as per the dependent: :destroy argument in the Airport class’ has_many declarations).Airport.all and Flight.all with it being from the output that the MEM airport and its associated flights were deleted.