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@email.com"
2.5.3 :006 > Person.first.update(email: "another@email.com")
Old:
New: another@email.com
=> true