This should work, but if you do it only on a couple of fields, I don’t understand why you just don’t write them explicitly
def before_validation
if condition == true
for x in [:attr1, :attr2, :attr3]
self.send("#{x}=", send("#{x}_was")
end
return false
end
end
maček source
share