I have the Shipping entity that references the Address entity twice, for example:
and the shipment model is as follows belonging twice to the entity of address (address_from, address_to):
class Shipment < ApplicationRecord
belongs_to :address_from, :class_name => 'Address'
belongs_to :address_to, :class_name => 'Address'
end
but I'm not very clear how it would look on the other side of the relationship model
class Address < ApplicationRecord
has_one :shipment
end
If it were a relationship between shipment and address it would be as follows:
rails g model Address
rails g model Shipment address:references
but I am not very clear how to relate them twice in this case
Any advice would be highly appreciated, thanks.
