Open bo-oz opened 4 years ago
What is strange is, when I look at another model, that is related to the User model (that has the name_cipertext encryption), that User model's name is de decyphered value for name. So in relationships it works, but when showing the original record, it doesn't.
Hi! Have you found any solution?
Well, here is my solution with app/models/concerns/entity/encryptable.rb:
module Entity
module Encryptable
def safe_send(value)
if self.class.lockbox_attributes.key?(value)
send(value)
else
super
end
end
end
end
class User < ApplicationRecord
include Entity::Encryptable
encrypts :email, :name
end
I have a strange issue. I'm using Lockbox to encrypt my database values for the user model. Lockbox stores the field as
{field_name}_ciphertext
. Besides encrypting the data, lockbox also provides instance methods with the original{field_name}
. I'd expect Rails Admin to be able to display the field, by calling the instance method, but somehow this doesn't work.If I manually create an instance method, that is basically an alias for the instance method Lockbox creates, it does work:
Any ideas how I could let Rails Admin call the correct method on the instance?