[英]Rails extend model with separate table
因此,我基本上有3個應用程序需要綁定在一起(通過使用Engine)。 一個公共網站,一個銷售點和一個經理(負責管理另外兩個)。 我想創建一個“產品”模型,其中包含與葡萄酒無關的所有產品詳細信息。 然后,我想要一個擴展產品的“葡萄酒”模型。 在數據庫中,我有兩個表...產品和葡萄酒。 wines表將僅具有特定於葡萄酒的屬性以及將其鏈接到相應產品表條目的product_id。
我知道如何在沒有一個模型擴展另一個模型的情況下 (通過belongs_to和has_ *)做到這一點,但是我不知道如何將其作為模型擴展來實現。
使用Rails 3.2.11
產品.rb
class Product < ActiveRecord::Base
...stuff goes in here
end
Wine.rb
class Wine < Product
...how do I ensure that the products table attributes and the wines table attributes are separately updated/created/etc.????
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.