There are two models, Airport and Flight

Flight may have a departure airport and arrival airport.

belongs_to :origin, class_name: 'Airport', foreign_key: :origin_id belongs_to :destination, class_name: 'Airport', foreign_key: :destination_id 

Airport can be on many flights as an airport of departure and airport of arrival

 has_many :flights, foreign_key: :destination_id has_many :flights, foreign_key: :origin_id 

    1 answer 1

    The association at the Airport should be like this:

     has_many :destination_flights, foreign_key: :destination_id, class_name: 'Flight' has_many :origin_flights, foreign_key: :origin_id, class_name: 'Flight'