0
以主价格对产品进行排序不能在我的项目中使用。 我使用标准大礼包安装。Sorting in spree
taxons_controller.rb显示方法的修改部分:
@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true))
@products = @searcher.retrieve_products
binding.pry
@products = @products.reorder('').send(:descend_by_master_price)
当撬控制台我写@products.reorder('').send(:descend_by_master_price)
,我得到以下几点:<Module:0x007f1e0048daa8>:0x3f8f041276b8>
。
但是,如果我写Product.all.reorder('').send(:descend_by_master_price)
一切工作正常。
而且在@products.reorder('').send(:descend_by_master_price).last
情况下,我得到的errror:
ActiveRecord::StatementInvalid: PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...UB' AND "spree_products"."id" IN (5, 1) ORDER BY "spree_pri...
所以,问题是DISTINCT ...
任何人都可以帮助吗?
哦,这样一个简单的解决方案!谢谢你! – nuT707