mongodb/mongoid · error · ArgumentError
Method '#{method}' is not allowed in from_hash
Error message
Method '#{method}' is not allowed in from_hash What it means
Error "Method '#{method}' is not allowed in from_hash" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/criteria.rb:86
# can include a "klass" key that specifies the model class for the criteria.
#
# @example Convert the hash to a criteria.
# Criteria.from_hash({ klass: Band, where: { name: "Depeche Mode" })
#
# @deprecated This method is deprecated and will
# be removed in a future release.
#
# @param [ Hash ] hash The hash to convert.
#
# @return [ Criteria ] The criteria.
#
# @raise [ ArgumentError ] If a method is not allowed in from_hash.
def from_hash(hash)
criteria = Criteria.new(hash.delete(:klass) || hash.delete('klass'))
hash.each_pair do |method, args|
method_sym = method.to_sym
unless ALLOWED_FROM_HASH_METHODS.include?(method_sym)
raise ArgumentError, "Method '#{method}' is not allowed in from_hash"
end
criteria = criteria.public_send(method_sym, args)
end
criteria
end
Mongoid.deprecate(self, :from_hash)
end
# Static array used to check with method missing - we only need to ever
# instantiate once.
CHECK = []
attr_accessor :embedded, :klass, :parent_document, :association
# Returns true if the supplied +Enumerable+ or +Criteria+ is equal to the results
# of this +Criteria+ or the criteria itself.
#View on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/criteria.rb:86 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/b0a48cf4bd3eb269.
Report an issue: GitHub.