我编辑了我的config / secrets.yml文件,但我仍然遇到同样的错误:
development:
secret_key_base: <%= ENV["random key"] %>
test:
secret_key_base: <%= ENV["random key"] %>
production:
secret_key_base: <%= ENV["random key"] %>
我的config / devise.rb文件如下所示:
Devise.setup do |config|
config.mailer_sender = "no-reply@myapp.com"
config.secret_key = ENV["random key"]
require 'devise/orm/active_record'
config.case_insensitive_keys = [ :email ]
config.strip_whitespace_keys = [ :email ]
config.skip_session_storage = [:http_auth]
config.stretches = Rails.env.test? ? 1 : 10
config.reconfirmable = true
config.password_length = 8..128
config.reset_password_within = 6.hours
config.sign_out_via = :delete
end
答案 0 :(得分:0)
您想在环境文件中设置随机密钥。我建议使用像https://github.com/bkeepers/dotenv之类的东西来管理它们。
在您放置的.env
文件中
SECRET_KEY=0639e5fce51aef9e3e552d60eaf951bf01c0fd1ea14d4173a4bdc56c7c71fc63cacf78a9c81d3f5a276bb9e567b0cec6d80ed22593ab480735b6aed08067e800
然后在上面的文件中执行
production:
secret_key_base: <%= ENV['SECRET_KEY'] %>