我有这个架构
产品.rb:
has_many :families_products
has_many :families, :through => :families_products
家庭.rb:
has_many :families_products
has_many :products, :through => :families_products
家庭产品.rb:
belongs_to :product
belongs_to :family
在families_product
表中我有一个名为的属性price
,当我在创建后尝试更新它时会引发错误。
1.9.3p0 :027 > family_product = FamiliesProduct.first
FamiliesProduct Load (0.9ms) SELECT `families_products`.* FROM `families_products` LIMIT 1
=> #<FamiliesProduct family_id: 1, product_id: 1, created_at: "2012-09-10 12:31:54", updated_at: "2012-09-10 12:31:54", points: nil>
1.9.3p0 :028 > family_product.points = 2
=> 2
1.9.3p0 :029 > family_product.save
(0.2ms) BEGIN
(0.7ms) UPDATE `families_products` SET `points` = 2, `updated_at` = '2012-09-10 12:53:05' WHERE `families_products`.`` IS NULL
(0.1ms) ROLLBACK
ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'families_products.'
in 'where clause': UPDATE `families_products` SET `points` = 2,
`updated_at` = '2012-09-10 12:53:05' WHERE `families_products`.`` IS NULL
我看到生成的查询有错误,所以有什么线索吗?