我想通过关联使用update_all,并且我得到mysql错误,任何人都知道为什么请吗?通过关联update_all
class Basket < ActiveRecord::Base
has_many :basket_items
has_many :articles, :through => :basket_items
def activate_articles
articles.update_all :active => true
end
end
class BasketItem < ActiveRecord::Base
belongs_to :basket
belongs_to :item
belongs_to :article
end
Mysql::Error: Unknown column 'basket_items.basket_id' in 'where clause': UPDATE `articles` SET `active` = 1 WHERE ((`basket_items`.basket_id = 114))
看起来像你的'basket_items'表设置不正确。你能向我们展示模式吗? – 2010-09-30 18:17:22
感谢您的期待丹尼尔,我已经更新了我原来的问题。 – dangerousdave 2010-09-30 19:32:40