xyz_order = "CASE WHEN [title] LIKE N'XYZ%' THEN 0 ELSE 1 END" xyz_post = Post.create title: "XYZ Post", body: "Test cased orders." assert_equal xyz_post, Post.order(Arel.sql(xyz_order)).first ...