首页 > 解决方案 > Rails 5.2 credentials.yaml.enc 和 master.key 在 Heroku 上不起作用

问题描述

我正在为一个新应用程序设置活动存储,并且在设置我的亚马逊凭据后无法让该应用程序在生产环境中运行。

  1. 我已将我的 s3 存储桶凭据包含在我的credentials.yaml.enc文件中
  2. 我已将我的RAILS_MASTER_KEY环境变量添加到 Heroku。
  3. 我已经根据这个在 storage.yml 文件中设置了我的 s3 存储桶。
  4. 我已将该config.active_storage.service = :amazon行添加到我的 production.rb 中。
  5. 我已添加config.require_master_key = true到我的 production.rb

当我尝试在 Heroku 上运行我的应用程序时,它不会加载。做 $ Heroku run rails console 会给我错误:

"/app/vendor/bundle/ruby/2.3.0/gems/aws-sigv4-1.0.2/lib/aws-sigv4/signer.rb:517:in `extract_credentials_provider': Cannot load `Rails.config.active_storage.service`: (Aws::Sigv4::Errors::MissingCredentialsError)
missing credentials, provide credentials with one of the following options:
- :access_key_id and :secret_access_key
- :credentials
- :credentials_provider"

据我所知,我已经按照 Rails 5.2 的预期方式设置了我的凭据。我尝试了各种资产预编译的东西都无济于事。当我尝试将我的亚马逊凭据添加为环境时。Heroku 中的变量,该应用程序在生产中运行良好。知道这里可能出了什么问题吗?

标签: ruby-on-railscredentialsrails-activestorageruby-on-rails-5.2

解决方案


Could it be that you forgot to add config.require_master_key = true to your production.rb?


推荐阅读