{"record":{"id":"b0a48cf4bd3eb269","repo":"mongodb/mongoid","slug":"method-method-is-not-allowed-in-from-hash","errorCode":null,"errorMessage":"Method '#{method}' is not allowed in from_hash","messagePattern":"Method '#(.+?)' is not allowed in from_hash","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/criteria.rb","lineNumber":86,"sourceCode":"      # can include a \"klass\" key that specifies the model class for the criteria.\n      #\n      # @example Convert the hash to a criteria.\n      #   Criteria.from_hash({ klass: Band, where: { name: \"Depeche Mode\" })\n      #\n      # @deprecated This method is deprecated and will\n      #  be removed in a future release.\n      #\n      # @param [ Hash ] hash The hash to convert.\n      #\n      # @return [ Criteria ] The criteria.\n      #\n      # @raise [ ArgumentError ] If a method is not allowed in from_hash.\n      def from_hash(hash)\n        criteria = Criteria.new(hash.delete(:klass) || hash.delete('klass'))\n        hash.each_pair do |method, args|\n          method_sym = method.to_sym\n          unless ALLOWED_FROM_HASH_METHODS.include?(method_sym)\n            raise ArgumentError, \"Method '#{method}' is not allowed in from_hash\"\n          end\n\n          criteria = criteria.public_send(method_sym, args)\n        end\n        criteria\n      end\n      Mongoid.deprecate(self, :from_hash)\n    end\n\n    # Static array used to check with method missing - we only need to ever\n    # instantiate once.\n    CHECK = []\n\n    attr_accessor :embedded, :klass, :parent_document, :association\n\n    # Returns true if the supplied +Enumerable+ or +Criteria+ is equal to the results\n    # of this +Criteria+ or the criteria itself.\n    #","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/criteria.rb#L68-L104","documentation":"Error \"Method '#{method}' is not allowed in from_hash\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/criteria.rb:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}