为 Spree::Product 添加了 default_scope 以对 spree 站点的主页进行排序,范围为default_scope :include => :product_taxons, :order => "spree_product_taxons.position"
. 这对其进行了排序,但是当我尝试更新产品时,出现以下错误
ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'spree_product_taxons.position' in 'order clause': UPDATE `spree_products` SET `count_on_hand` = 100 WHERE `spree_products`.`id` = 108 ORDER BY spree_product_taxons.position`
首先,为什么要尝试订购更新?好吧,这个领域确实存在
Spree::ProductTaxon
=> Spree::ProductTaxon(id: integer, created_at: datetime, updated_at: datetime, product_id: integer, taxon_id: integer, position: integer)