I have a business requirement for a per-user key. I would like to have table like:
# Table name: data # # secret :string # user_id :integer not null
and I would like to have the secret encrypted with a different key for each user. I’ve seen some alternative gems that have this support, for example with Lockbox I can do:
class Data < ApplicationRecord lockbox_encrypts :secret, key: :some_method def some_method # choose key based on user_id end end
I’d prefer to use Rails 7 encryption if possible. Does anyone know a way to accomplish this kind of behavior?