所以我基本上有 3 个应用程序需要捆绑在一起(通过使用引擎)。一个公共网站、一个销售点和一个经理(管理另外两个)。我想创建一个“产品”模型,其中包含与葡萄酒无关的所有产品细节。然后我想要一个扩展 Product 的“Wine”模型。在数据库中,我有两张表……产品和葡萄酒。wines 表将仅具有特定于 wine 的属性和将其链接到相应产品表条目的 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