mardi 26 mai 2015

Sorting a Rails active record

I have a table A(:name, :address, :country_id). I run this query

ids = [1,2,3]
A.where(country_id: ids)

But, I want to get the results in this order : records containing country_id = 2 first, then 1 and then 3.

How should I write this query?

Aucun commentaire:

Enregistrer un commentaire