【发布时间】:2013-02-14 21:31:44
【问题描述】:
所以我基本上有 3 个应用程序需要捆绑在一起(通过使用引擎)。一个公共网站、一个销售点和一个经理(管理另外两个)。我想创建一个“产品”模型,其中包含与葡萄酒无关的所有产品细节。然后我想要一个扩展 Product 的“Wine”模型。在数据库中,我有两张表……产品和葡萄酒。 wines 表将仅具有特定于 wine 的属性和将其链接到相应产品表条目的 product_id。
我知道如何做到这一点没有一个模型扩展另一个模型(通过belongs_to和has_*),但我不明白如何作为模型扩展来做到这一点。
使用 Rails 3.2.11
Product.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
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 rails-activerecord