0
我有一個應用程序,客戶可以下訂單以將項目發送到目的地。訂單需要跟蹤客戶和目的地地址。添加訂單會使活動記錄關聯複雜化
我開始用下面的活動記錄關聯:
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
兩個問題:
有在ORDER兩個
has_one
協會沒有對稱belongs_to
。這似乎是錯誤的,但它對於客戶或目的地在概念上也是沒有意義的,部分是因爲訂單和客戶或目的地只有一個地址。ORDER的正確遷移是什麼?
在此先感謝。