I think of the best solution to the problem. Let's say that we have a list of ActiveRecord model identifiers:
ids = [1, 100, 5, 30, 4, 2, 88, 44]
Then I would like to make a query that selects all users, for example, with identifiers from the list, but to maintain order. If i do
User.where(id: ids)
the answer will be a list of users with asc order by id, but I want the order to be the same as in the array.
What do you think is the best solution here? Select all users and then manage the list of ActiveRecord objects? There may be a smarter way to do this.
Thanks!
source share