我有一个名为Price以下列的模型:
create_table :prices do |t|
t.decimal :cost
t.integer :product_id
t.integer :store_id
t.decimal :cost_per_unit
t.decimal :unit_amount
t.string :unit
end
在我的应用程序中,价格可以使用cost列,也可以使用其他 3 cost per unit、、unit amount和unit。既然我有这个规则,那么创建另一个名为PricePerUnitor的模型是否明智UnitPrice?现在我打算只使用价格模型和两个单独的表格。你会怎么办?如果我计划有专门处理这两种不同价格类型的列,从长远来看,什么会更好?