0
私は、顧客が注文をして商品を宛先に送ることができるアプリを持っている。注文は、顧客と宛先アドレスの両方を追跡する必要があります。注文を追加するとアクティブなレコードの関連付けが複雑になる
私は、次のActive Recordの団体で始まる:
CUSTOMER
has_one :customer_address
CUSTOMER_ADDRESS
belongs_to :customer
DESTINATION
has_one :destination_address
DESTINATION_ADDRESS
belongs_to :destination
は今、私は注文の概念を追加したいです。
CUSTOMER
has_one :customer_address
has_many :orders
CUSTOMER_ADDRESS
belongs_to :customer
DESTINATION
has_one :destination_address
DESTINATION_ADDRESS
belongs_to :destination
ORDER
belongs_to :customer
has_one :customer_address, through: :customer
has_one :destination_address, through :destination
つの質問:
ために、2つの
has_one
団体のための対称belongs_to
ありませんは、だから私は、次のように変更します。これは間違っているように見えますが、顧客または宛先のために多くの注文と唯一の住所があるため、顧客または宛先の概念が概念的には
belong_to
の注文には意味がありません。ORDERの正しい移行は何ですか?
ありがとうございます。