我对 Ransack 有一个非常奇怪的问题,我很难确定。我在Solidus中有一个表格,其中显示了供管理员搜索的产品列表。此产品列表可以按多个列名称(即sku
、name
和price
)排序。但是,当我尝试按sku
列排序时,列表在列表的最后约 30 项中出现乱序(总共列出了大约 3,000 种产品)。似乎它sku
在某个点之后停止对名称进行排序,几乎在最后。这只发生在我按sku
列排序时,而不是name
or price
。
这是我用于这些列的代码:
<thead>
<tr data-hook="admin_products_index_headers">
<th><%= sort_link @search, :sku, Spree::Product.human_attribute_name(:sku), { default_order: "desc" }, {title: 'admin_products_listing_sku_title'} %></th>
<th></th>
<th><%= sort_link @search, :name, Spree::Product.human_attribute_name(:name), { default_order: "desc" }, {title: 'admin_products_listing_name_title'} %></th>
<th class="align-right"><%= sort_link @search,:master_default_price_amount, Spree::Product.human_attribute_name(:price), {}, {title: 'admin_products_listing_price_title'} %></th>
<th data-hook="admin_products_index_header_actions" class="actions"></th>
</tr>
</thead>
我真的不知道该sku
列在接近尾声的某个点之后导致排序变得不正确。sku
字符串如下所示:AB123456
. 它们都以字母开头AB
,然后是标识产品的唯一整数。据我所知,这应该是 Ransacksort_link
可以毫无困难地处理的事情。但是,唉,我在这里挠头……