Reputation: 2911
I want to create new record in spree_products_taxons table with ActiveRecord (not with pure SQL), but:
1.9.3-head :003 > Spree::ProductsTaxon.create(product_id: 666, taxon_id: 777)
NameError: uninitialized constant Spree::ProductsTaxon
Where am i wrong?
ps. In my schema file:
create_table "spree_products_taxons", :id => false, :force => true do |t|
t.integer "product_id"
t.integer "taxon_id"
end
Upvotes: 0
Views: 210
Reputation: 636
You can try something like this
product = Spree::Product.find(666)
taxon = Spree::Taxon.find(777)
product.taxons << taxon
product.save
taxons = product.taxons
Upvotes: 1