You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm struggling to create a custom field for fields encrypted by the symmetric-encryption gem.
For what I learned from your documentation and your source code, I just need to implement a new type and implement the method parse_value(value) which is called prior to the query build.
So, that's is my code:
module RailsAdmin
module Config
module Fields
module Types
class EncryptedField < RailsAdmin::Config::Fields::Types::String
RailsAdmin::Config::Fields::Types::register(self)
def parse_value(value)
SymmetricEncryption.encrypt(value)
end
end
end
end
end
end
RailsAdmin.config do |config|
config.model 'User' do
list do
field :email, :encrypted_field do
searchable ['encrypted_email']
queryable true
end
end
end
Before forking and removing one call for the parse_value method, I would like to know if there's a reason for this (will it break something else?). If no, I can submit a PR.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi there,
I'm struggling to create a custom field for fields encrypted by the
symmetric-encryption
gem.For what I learned from your documentation and your source code, I just need to implement a new type and implement the method
parse_value(value)
which is called prior to the query build.So, that's is my code:
Ok, the problem is on the
ActiveRecord
adapter, which calls the methodparse_value
twice before building the query:https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/adapters/active_record.rb#L102
https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/adapters/active_record.rb#L127
Before forking and removing one call for the
parse_value
method, I would like to know if there's a reason for this (will it break something else?). If no, I can submit a PR.Thanks!
The text was updated successfully, but these errors were encountered: