Open edouard-per-angusta opened 3 years ago
wonderful edge case.
there is no way to determine that you have kids (without a query) I guess there is a way to know that you are a new node - so we could skip the check in that instance
Could also only add this validation in has_ancestry
when the depth validation is added.
This just feels like an expensive check.
Curious, are you running this on postgres or mysql? Probably doesn't make a difference, but we approach them slightly differently.
Hi! I try to validate a maximal depth, but it seems that Rails validations are skipped when cached depth is updated after a parent has been updated.
For example, given I want this maximal depth to be 1:
For now I've added a validation on update like:
But I was wondering if there was a built-in system for that? Like something checking if there is any other
ActiveModel::Validations::NumericalityValidator
on theancestry_depth
attribute?Thanks! :)