lib/symmetric_encryption/railtie.rb in symmetric-encryption-4.1.0.beta1 vs lib/symmetric_encryption/railtie.rb in symmetric-encryption-4.1.0
- old
+ new
@@ -27,11 +27,16 @@
# Loaded before Active Record initializes since database.yml can have encrypted
# passwords in it
config.before_configuration do
# Check if already configured
unless ::SymmetricEncryption.cipher?
- app_name = Rails::Application.subclasses.first.parent.to_s.underscore
- config_file = Rails.root.join('config', 'symmetric-encryption.yml')
+ app_name = Rails::Application.subclasses.first.parent.to_s.underscore
+ config_file =
+ if (env_var = ENV['SYMMETRIC_ENCRYPTION_CONFIG'])
+ Pathname.new File.expand_path(env_var)
+ else
+ Rails.root.join('config', 'symmetric-encryption.yml')
+ end
if config_file.file?
begin
::SymmetricEncryption::Config.load!(file_name: config_file, env: ENV['SYMMETRIC_ENCRYPTION_ENV'] || Rails.env)
rescue ArgumentError => exc
puts "\nSymmetric Encryption not able to read keys."