From 0e9e59953fa5360750287fe45a102633f7e54f2b Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 23 Mar 2019 09:07:57 +0900 Subject: Add `secret_key_base` when creating new credential file Since `secret_key_base` is expected to be included in credential file, `secret_key_base` should be included even if re-create the file. This is the same behavior as creating a new app. When env is specified, it may be unnecessary, so I added it only when not specifying env. --- .../lib/rails/commands/credentials/credentials_command.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/commands/credentials') diff --git a/railties/lib/rails/commands/credentials/credentials_command.rb b/railties/lib/rails/commands/credentials/credentials_command.rb index a22b1f3f84..e23a1b3008 100644 --- a/railties/lib/rails/commands/credentials/credentials_command.rb +++ b/railties/lib/rails/commands/credentials/credentials_command.rb @@ -56,7 +56,11 @@ module Rails end def ensure_credentials_have_been_added - encrypted_file_generator.add_encrypted_file_silently(content_path, key_path) + if options[:environment] + encrypted_file_generator.add_encrypted_file_silently(content_path, key_path) + else + credentials_generator.add_credentials_file_silently + end end def change_credentials_in_system_editor @@ -96,6 +100,13 @@ module Rails Rails::Generators::EncryptedFileGenerator.new end + + def credentials_generator + require "rails/generators" + require "rails/generators/rails/credentials/credentials_generator" + + Rails::Generators::CredentialsGenerator.new + end end end end -- cgit v1.2.3