method
in_order_of
v7.0.0 -
Show latest stable
- Class:
ActiveRecord::QueryMethods
in_order_of(column, values)public
Allows to specify an order by a specific set of values. Depending on your adapter this will either use a CASE statement or a built-in function.
User.in_order_of(:id, [1, 5, 3]) # SELECT "users".* FROM "users" ORDER BY FIELD("users"."id", 1, 5, 3)