Rails prodution secret_key_base问题

ERROR:Missing secret_key_base for ‘production’ environment, set this string with rails credentials:edit (ArgumentError)
rails 在5.2以后就有了credentials 但是同样支持secrets.yml
源码中有三种解决方案:这里讲一下1.credentials,2.secrets
在这里插入图片描述

1.credentials

#删除 rm -rf config/credentials.yml.enc
#执行 没有master.key和credentials.yml.enc 会在config下生成
 EDITOR="mate --wait" bin/rails credentials:edit
# 编辑credentials.yml.enc
 EDITOR=vim rails credentials:edit 
 #进入项目
 rails c
 输入:Rails.application.credentials.secret_key_base

一般master.key是不准提交的
不提交生产环境的解决方案待研究

secrets

在这里插入图片描述

添加 config/secrets.yml

production:
  secret_key_base: 0b7536201e9b61efc7ad15305b7ef18bee66857abb257bf89700e42ee99d803cccf585ff17ca880d0055d1139cc5d49363c866f34c862214b627d660fb17be2b
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值