ruby-on-rails - Rails 5.2 credentials.yaml.enc 和 master.key 在 Heroku 上不起作用
问题描述
我正在为一个新应用程序设置活动存储,并且在设置我的亚马逊凭据后无法让该应用程序在生产环境中运行。
- 我已将我的 s3 存储桶凭据包含在我的
credentials.yaml.enc
文件中 - 我已将我的
RAILS_MASTER_KEY
环境变量添加到 Heroku。 - 我已经根据这个在 storage.yml 文件中设置了我的 s3 存储桶。
- 我已将该
config.active_storage.service = :amazon
行添加到我的 production.rb 中。 - 我已添加
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 中的变量,该应用程序在生产中运行良好。知道这里可能出了什么问题吗?
解决方案
Could it be that you forgot to add config.require_master_key = true
to your production.rb
?
推荐阅读
- c++ - 为什么在 C++ 中不可能对声明为数组的变量进行递增或执行数学运算,例如乘法运算
- javascript - 我如何使用 javascript 将结果从 html 表单输出到桌面上的文本文件中?
- c++ - (C++) 我的函数不返回数组
- flow - 来自传感器 c# 的读数的移动平均值
- typescript - 在 TypeScript 中声明 s 表达式类型
- php - 是否可以反转正则表达式?
- c - 返回单个整数,即solve(A) mod 1000000007 的值
- php - 选择计数组并输出到带有键和值的数组
- django - Django 自定义登录 - 表单有效但没有错误
- php - 数据库连接 PHP 中的未知错误与 MySQL 服务器工作台不在 phpmyadmin 中