rails_admin gem config to see original fields encrypted in db using attr_encrypted gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RailsAdmin.config do |config| | |
# include required models | |
required_models = ["Blog", "Comment", "User", "Other"] | |
required_models.each do |act_model| | |
model_class = Object.const_get(act_model) | |
config.model act_model do | |
# find all attrs that start with encrpted_ (default attr_encrypted convention; change as required) | |
encrypted_attrs = model_class.column_names.select{|k| k.match("encrypted_")} | |
list do | |
include_all_fields | |
encrypted_attrs.each do |c| | |
field c.to_sym do | |
lab = c.gsub('encrypted_','') | |
label lab.capitalize | |
formatted_value do | |
model_class.send("decrypt_#{lab}",value) | |
end | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment