Rails 7.1 adds support for multi-column ordering in ActiveRecord::Batches - BigBinary Blog

04-Oct-2023 514
In Rails versions prior to 7.1, when batch processing records with a composite primary key, like id_1 and id_2, developers could use the :asc or :desc argument to control the sorting order. However, there was a limitation in how this sorting worked. When you specified the sorting order using :asc or :desc, it affected both id_1 and id_2 simultaneously. In other words, if you requested ascending order, both id_1 and id_2 would be sorted in ascending order together. Similarly, if you requested descending order, both id_1 and id_2 would be sorted in descending order together.This limitation had practical implications, especially when you needed to sort records by different criteria for each part of the composite primary key.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle