diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-12-05 21:41:19 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-12-18 08:04:15 +0900 |
commit | 35373219c91ea8096ef2f8e7f3c62bcd46f436be (patch) | |
tree | 568eddd5f7ef943f297c8cfe56d1087d371d5122 /railties/lib/rails/commands/credentials | |
parent | daf15f58b943d85d8fb726590ae94f77ca0a5d5f (diff) | |
download | rails-35373219c91ea8096ef2f8e7f3c62bcd46f436be.tar.gz rails-35373219c91ea8096ef2f8e7f3c62bcd46f436be.tar.bz2 rails-35373219c91ea8096ef2f8e7f3c62bcd46f436be.zip |
Raise an error only when `require_master_key` is specified
To prevent errors from being raise in environments where credentials
is unnecessary.
Context: https://github.com/rails/rails/issues/31283#issuecomment-348801489
Fixes #31283
Diffstat (limited to 'railties/lib/rails/commands/credentials')
-rw-r--r-- | railties/lib/rails/commands/credentials/credentials_command.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/credentials/credentials_command.rb b/railties/lib/rails/commands/credentials/credentials_command.rb index 8085f07c2b..385d3976da 100644 --- a/railties/lib/rails/commands/credentials/credentials_command.rb +++ b/railties/lib/rails/commands/credentials/credentials_command.rb @@ -33,8 +33,7 @@ module Rails def show require_application_and_environment! - say Rails.application.credentials.read.presence || - "No credentials have been added yet. Use bin/rails credentials:edit to change that." + say Rails.application.credentials.read.presence || missing_credentials_message end private @@ -67,6 +66,14 @@ module Rails Rails::Generators::CredentialsGenerator.new end + + def missing_credentials_message + if Rails.application.credentials.key.nil? + "Missing master key to decrypt credentials. See bin/rails credentials:help" + else + "No credentials have been added yet. Use bin/rails credentials:edit to change that." + end + end end end end |