I have this:
collectedclientids = user.favorites.pluck(:client_id)
and it gives me this:
=> [18, 34, 1, 90]
Now, I want to fetch clients in the exact same order and have an array with them, or an ActiveRelation.
It'd be similar in ruby to do this:
clientsordered = collectedclientids.each_with_object([]) { |id, array| array << Client.find(id) }
.. which gives me an array of the clients in the same order with client_id [18, 34, 1, 90]
But how can I accomplish this in rails? Any ideas on methods to use?