1
こんにちは。カートに商品を追加する際に問題が発生しています。レールアジャイルブックから。異なる属性を持つ商品に追加したい場合(アパート、車)異なる商品タイプのカートに商品を追加する
class Products
has_many :line_items
attributes :name, :price, :content
end
class LineItem
belongs_to :products
belongs_to :carts
end
class Cart
has_many :line_items
end
class Car
attributes :name, :car_type, :color
end
class Apartment
attributes :name, :size, :location
end
class Order
attr :buyer_details, :pay_type
end
お客様はカートとe.x.の商品を追加します。 2ベッドルームの賃貸料、リムジンの賃料と支払いを望みます。カートに追加する方法。私がapartment_idとcar_idをlineitemsに入れたら、それは汚染されますか?正しいアプローチ、正しい練習が必要です。全てに感謝。
これは私の質問です。それが悪いデザインの場合、それを行う正しい方法は何ですか? –
上記の回答があなたのために役立つ例で更新されました – TomDunning