我想用ActiveRecord (不是纯SQL)在spree_products_taxons表中创建新记录,但是:
1.9.3-head :003 > Spree::ProductsTaxon.create(product_id: 666, taxon_id: 777)
NameError: uninitialized constant Spree::ProductsTaxon我哪里错了?
ps。在我的架构文件中:
create_table "spree_products_taxons", :id => false, :force => true do |t|
t.integer "product_id"
t.integer "taxon_id"
end发布于 2012-09-18 18:38:07
你可以试试这样的东西
product = Spree::Product.find(666)
taxon = Spree::Taxon.find(777)
product.taxons << taxon
product.save
taxons = product.taxonshttps://stackoverflow.com/questions/12473552
复制相似问题