I have a very strange issue with Ransack that I'm finding hard to pin down. I have a table in Solidus which displays a product listing for an administrator to search through. This product listing can be sorted by several column names (namely, sku
, name
, and price
). However, when I try to sort by the sku
column, the listing becomes out of order within the last ~30 items of the listing (there are about 3,000 products listed in total). It seems that it stops sorting the sku
names after a certain point, nearly at the end. This only happens when I sort by the sku
column, not name
or price
.
This is the code I'm using for these columns:
<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>
I really have no idea what about the sku
column is causing the sorting to become incorrect after this certain point near the end. The sku
strings look like this: AB123456
. All of them start with the letters AB
and then a unique integer which identifies the product. As far as I can tell, this should totally be something Ransack's sort_link
can handle without trouble. But alas, here I am scratching my head...