Skip to content

Instantly share code, notes, and snippets.

@niyando
Last active August 29, 2015 14:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
rails_admin gem config to see original fields encrypted in db using attr_encrypted gem
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