我有一个Brand模型和一个Price模型,因此:
品牌.rb
class Brand < ActiveRecord::Base
attr_accessible :name, :a4_single, :a4_double, :a3_double, :two_a3_double
has_many :prices, :dependent => :destroy
end
价格.rb
class Price < Brand
attr_accessible :type, :quantity, :price, :brand_id
belongs_to :brand
end
我希望能够在每个产品列中插入多 Price条记录,例如 10条记录 in 、8 条 in 、2条 in和 8 条 in 。Price:a4_single:a4_double:a3_double:two_a3_double
我只是猜测has_many上面定义的关系是正确的,我真的不知道如何从这里着手。