lib/symmetric_encryption/railtie.rb in symmetric-encryption-3.9.1 vs lib/symmetric_encryption/railtie.rb in symmetric-encryption-4.0.0.beta3
- old
+ new
@@ -14,14 +14,10 @@
# )
# end
# end
config.symmetric_encryption = ::SymmetricEncryption
- rake_tasks do
- load 'symmetric_encryption/railties/symmetric_encryption.rake'
- end
-
# Initialize Symmetry. This will look for a symmetry.yml in the config
# directory and configure Symmetry appropriately.
#
# @example symmetric-encryption.yml
#
@@ -33,21 +29,23 @@
# 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')
if config_file.file?
begin
- ::SymmetricEncryption::Config.load!(config_file, Rails.env)
+ ::SymmetricEncryption::Config.load!(file_name: config_file, env: Rails.env)
rescue ArgumentError => exc
puts "\nSymmetric Encryption not able to read keys."
puts "#{exc.class.name} #{exc.message}"
- puts "To generate key files: bin/rails generate symmetric_encryption:new_keys #{Rails.env}\n\n"
+ puts "To generate a new config file and key files: symmetric-encryption --generate --key-path /etc/#{app_name} --app_name #{app_name}\n\n"
+ raise(exc)
end
else
puts "\nSymmetric Encryption config not found."
- puts "To generate one for the first time: bin/rails generate symmetric_encryption:config\n\n"
+ puts "To generate a new config file and key files: symmetric-encryption --generate --key-path /etc/#{app_name} --app_name #{app_name}\n\n"
end
end
end
end