mongodb/mongoid · error · ArgumentError
A class which includes Mongoid::Document is expected
Error message
A class which includes Mongoid::Document is expected
What it means
Error "A class which includes Mongoid::Document is expected" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/document.rb:303
return unless attributes.key?(stored) || !relation.blank?
if relation.nil?
attributes.delete(stored)
else
attributes[stored] = relation.send(:as_attributes)
end
end
# Checks that the given argument is an instance of `Mongoid::Document`.
#
# @param klass [ Class ] The class to test.
#
# @raise [ ArgumentError ] if the class does not include
# Mongoid::Document.
def mongoid_document_check!(klass)
return if klass.include?(Mongoid::Document)
raise ArgumentError, 'A class which includes Mongoid::Document is expected'
end
# Constructs a hash representing the internal state of this object,
# suitable for passing to #internal_state=.
#
# @return [ Hash ] the map of internal state values
def internal_state
{
id: _id,
changed_attributes: changed_attributes,
errors: errors,
new_record: new_record?,
destroyed: destroyed?,
discriminator_key_was: self.class.discriminator_value
}
end
# Updates the value of the discriminator_key for this object, setting itsView on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/document.rb:303 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/a96b53c87e152939.
Report an issue: GitHub.