I want to sort my where condition result in the order i am passing the values in array . what i am doing is i have an array of ids
ids = [80, 20, 3, 91, 84, 90, 98, 97, 68, 99, 92, 73]
When i am passing this array to where condition like :
products = Product.where(id: ids)
its returning the result active record relation in different order (random order)something like :
=>[ 20 ,84, 3,98 , .............. ]
(this is active record relation object i have mention only ids here )
But i want it to return the object in same order i am passing the the values like (In active record relation object not an array)
=> [80, 20, 3, 91, 84, 90, 98, 97, 68, 99, 92, 73]
How can i do this .
Aucun commentaire:
Enregistrer un commentaire