gpt4 book ai didi

ruby-on-rails - rails : How to fix "Missing secret_key_base for ' production' environment"

转载 作者:行者123 更新时间:2023-12-03 13:23:51 28 4
gpt4 key购买 nike

我根本无法通过消息:

Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit` (ArgumentError)

我有 Rails 5.2.0,然后跑了
EDITOR=vim rails credentials:edit

和里面:
production:
secret_key_base: xxxxxxxxxxxxxxxxxxxxxxx

保存并在终端中:
RAILS_ENV=production rails c

我错过了什么吗?我重新启动了服务器并遇到了同样的问题,但在开发模式下没有问题。

最佳答案

保持默认 secrets.yml文件

# config/secrets.yml
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

development:
secret_key_base: static_secret_key

test:
secret_key_base: static_test_secret_key

#not_indented: key for all env in once
secret_key_base: global_key_for_all_env
RAILS_ENV=production SECRET_KEY_BASE=production_test_key rails c

如果使用 Rails 5.2.0,添加到下面的生产环境,检查这个 LINK
config.require_master_key = true    #config/environments/production.rb

关于ruby-on-rails - rails : How to fix "Missing secret_key_base for ' production' environment",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51466887/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com