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:
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
Ok, the problem is on the ActiveRecord adapter, which calls the method parse_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!
Hi there,
I'm struggling to create a custom field for fields encrypted by the
symmetric-encryptiongem.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
ActiveRecordadapter, which calls the methodparse_valuetwice 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_valuemethod, 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!