I’m trying to set up a fairly unique implementation of active record encryption with a custom key provider. The custom key provider uses Current.account
in the encryption_key
and decryption_keys
methods, however Current.account may not always be set. The records I am encrypting are “account owned”, meaning they should always have a reference to an account via record.account
. I was thinking I could provide the record to the custom key provider via something like:
def initialize(record)
@record = record
end
and in my model file provide a proc to key_provider
like:
encrypts :attribute, key_provider: ->(record) { CustomKeyProvider.new(record) }
But the problem is key_provider does not accept a proc. Is there another way I can provide a record to the key provider?