Criteria#order_by is designed to be similar to SQL's "ORDER BY" but I'm not totally satisfied by it. I have a select field with order statements like "price asc", "created_at desc". I want to call just order_by(params[:order]) but it does not accept a one-string argument. I've patched it to work like I want. Maybe it is a good idea to take this into core.
class Mongoid::Criteria module OrderableByString # order_by("foo asc") equals order_by("foo", "asc") def order_by(*args) string = args.first if string.is_a?(String) and args.size == 1 field, direction = string.split(" ") super(field, direction) else super end end alias order order_by end include OrderableByString end