疯狂寻找没有任何分类单元的产品
Spree find product without any taxons
如何在 spree 中找到所有没有添加类群的产品?
如果我 运行 Spree::Product.first.taxons
我得到 ActiveRecord::Associations::CollectionProxy
产品具有的分类单元数组,但我如何找到该数组为空的所有产品?
我试过了
Spree::Product.where(taxons: nil)
但这又回来了
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column spree_products.taxon_id does not exist
Spree::Product.ids - Spree::Classification.pluck(:product_id)
returns 没有任何分类单元的所有产品 ID 的列表,效果很好。
Spree::Product.left_outer_joins(:taxons).where('taxons.id IS NULL')
如何在 spree 中找到所有没有添加类群的产品?
如果我 运行 Spree::Product.first.taxons
我得到 ActiveRecord::Associations::CollectionProxy
产品具有的分类单元数组,但我如何找到该数组为空的所有产品?
我试过了
Spree::Product.where(taxons: nil)
但这又回来了
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column spree_products.taxon_id does not exist
Spree::Product.ids - Spree::Classification.pluck(:product_id)
returns 没有任何分类单元的所有产品 ID 的列表,效果很好。
Spree::Product.left_outer_joins(:taxons).where('taxons.id IS NULL')