Today I Learned

hashrocket A Hashrocket project

ActiveRecord find with array is an ordered return

You probably already know that passing an Array to an ActiveRecord.find will do an IN query and return the results.


=> [, , ]

But did you know that the order of the array affects the returned result order? This is an order not done at the database level.


=> [, , ]
See More #rails TILs
Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.