-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Validations
-
None
The method #read_attibute_for_validation is supposed to return the value used for validation. Thus it should return the raw value and not utilize the getter from send(attr).
It crops up as a problem in Rails https://github.com/rails/rails/blob/a3b1105ada3da64acfa3843b164b14b734456a50/activemodel/lib/active_model/validator.rb#L165 whenever you use allow_nil or allow_blank on the field and are overriding the getter.
Since the raw value is what should be used for validation, I would argue that instead of send(attr) it should return attributes[attribute].