find_in_batches does not use given order but uses id asc

青春壹個敷衍的年華 提交于 2019-12-08 07:14:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!