I am thinking about the best solution for a problem. Let\'s say that we have a list of ids of ActiveRecord model:
ids = [1, 100, 5, 30, 4, 2, 88, 44]
if you want to get a result of Model::ActiveRecord_Relation
order(Arel.sql("field(id, ids.join(', ') asc"))
Arel.sql is required to prevent the message in log:
Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s)