问题
How can I use ordering as it is?
Any help will be appreciated. Thank u!
see the code-
selected_catalog_products.find_in_batches(batch_size: 4) do |cps|
# my code
end
回答1:
It’s not possible to set the order. The order is automatically set to ascending on the primary key (“id ASC”) to make the batch ordering work.
http://apidock.com/rails/ActiveRecord/Batches/find_in_batches
来源:https://stackoverflow.com/questions/32005165/find-in-batches-does-not-use-given-order-but-uses-id-asc