origin icon indicating copy to clipboard operation
origin copied to clipboard

Order without direction gives an unhelpful error message

Open gaffneyc opened this issue 12 years ago • 1 comments

If you fail to give a direction for an order you get this really unhelpful error message:

"field_one".__sort_option__
NoMethodError:
  undefined method `to_direction' for nil:NilClass

What would be the best approach here? Converting an app from another ORM that defaults to ascending order if not specified and was thinking of doing that.

If there is a preferred direction for this I'll put together a pull request with a fix.

gaffneyc avatar Jun 24 '13 03:06 gaffneyc

Agreed. Really this should be mentioned in one of[1] the Mongoid docs[2]. I had to do some DuckDuckGoing to even figure out it was an option, and issue searching to figure out the solution.

[1] http://rdoc.info/gems/mongoid/3.1.6/Mongoid/Relations/Macros/ClassMethods#has_many-instance_method [2]http://mongoid.org/en/mongoid/docs/relations.html

sshaw avatar Sep 26 '14 22:09 sshaw