The attribute_was method does not appear to return the old value from an encrypted value:
class Person < ApplicationRecord
attr_encrypted :email, key: "Some key"
before_update :check
private
def check
puts "Old: #{self.email_was}"
puts "New: #{self.email}"
end
end
This can be seen in the console:
2.5.3 :006 > Person.first.email
=> "[email protected]"
2.5.3 :006 > Person.first.update(email: "[email protected]")
Old:
New: [email protected]
=> true