validates_serialized icon indicating copy to clipboard operation
validates_serialized copied to clipboard

Define `record` to let ValidateableObject access the outer model

Open asilano opened this issue 8 years ago • 0 comments

I encountered a situation where I needed to give a validation on a serialized Hash access to the outer, "real" object - for instance, validations conditional on some state of the outer object (although there are other applications - I personally have a custom validation that has to check a complex predicate which may depend on state of the outer object).

This change defined @record as a readable member on ValidateableObject, which is the inner object passed to if: predicates. record will point to the outer AR::Base object through arbitrary levels of nesting (array in hash, hash in array etc).

asilano avatar Dec 13 '17 16:12 asilano