Skip to content

Instantly share code, notes, and snippets.

@mzaragoza
Created September 2, 2016 14:30
Show Gist options
  • Save mzaragoza/33fe2db30682071566325c72215efdcd to your computer and use it in GitHub Desktop.
Save mzaragoza/33fe2db30682071566325c72215efdcd to your computer and use it in GitHub Desktop.
Best way to store bank account information of users?
#file name and path app/models/user.rb
class User
attr_encrypted :bank_account_number, key: ENV['salt']
end
#file name and path config/application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
module ProjectName
class Application < Rails::Application
config.active_record.raise_in_transactional_callbacks = true
config.before_initialize do
dev = File.join(Rails.root, 'config', 'config.yml')
YAML.load(File.open(dev)).each do |key,value|
ENV[key.to_s] = value
end if File.exists?(dev)
end
end
end
#file name and path config/config.yml
# var section
salt: 'This is a key that is 256 bits!!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment