mongodb/mongoid · error · ArgumentError
cannot translate #{value.inspect} (#{value.class}) to a dire
Error message
cannot translate #{value.inspect} (#{value.class}) to a direction specification What it means
Error "cannot translate #{value.inspect} (#{value.class}) to a direction specification" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/criteria/translator.rb:38
# Translator.to_direction("1")
# Translator.to_direction(-1)
# Translator.to_direction(score: { "$meta": "textScore" })
#
# @param [ Hash | Numeric | String | Symbol ] value The value to convert.
#
# @return [ Hash | Numeric ] The direction.
def to_direction(value)
case value
when Hash
value
when Numeric
value
when String
/desc/i.match?(value) ? -1 : 1
when Symbol
to_direction(value.to_s)
else
raise ArgumentError, "cannot translate #{value.inspect} (#{value.class}) to a direction specification"
end
end
end
end
end
View on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/criteria/translator.rb:38 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23).
Data as JSON: /api/errors/7db9d8c0625efc54.
Report an issue: GitHub.