mongodb/mongoid · error · Mongoid::Errors::InvalidDependentStrategy
Invalid dependent strategy: %{invalid_strategy}.
Error message
Invalid dependent strategy: %{invalid_strategy}. What it means
Error "Invalid dependent strategy: %{invalid_strategy}." thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/association/depending.rb:78
klass.dependents_owner = klass
end
klass.dependents.push(association) if association.dependent && !klass.dependents.include?(association)
end
end
# Validates that an association's dependent strategy is
# within the allowed enumeration.
#
# @param [ Mongoid::Association::Relatable ] association
# The association to validate.
#
# @raises [ Mongoid::Errors::InvalidDependentStrategy ]
# Error if invalid.
def self.validate!(association)
return if STRATEGIES.include?(association.dependent)
raise Errors::InvalidDependentStrategy.new(association,
association.dependent,
STRATEGIES)
end
# Perform all cascading deletes, destroys, or nullifies. Will delegate to
# the appropriate strategy to perform the operation.
#
# @example Execute cascades.
# document.apply_destroy_dependencies!
def apply_destroy_dependencies!
self.class._all_dependents.each do |association|
if dependent = association.try(:dependent)
send("_dependent_#{dependent}!", association)
end
end
end
privateView on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/association/depending.rb:78 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/758fdd5e676cb124.
Report an issue: GitHub.