11

我添加了 Devise gem,然后按照说明运行rails generate devise:install,结果如下:

/usr/local/rvm/gems/ruby-1.9.3-p194/gems/devise-3.2.4/lib/devise/rails/routes.rb:487:in        `raise_no_secret_key': Devise.secret_key was not set. Please add the following to your Devise initializer: (RuntimeError)

config.secret_key = 'abc123'

Please ensure you restarted your application after installing Devise or setting the key.

如何“重新启动”我的应用程序?以及如何以及在哪里设置密钥?

4

2 回答 2

21

为了生成秘密运行:

bundle exec rake secret

并将结果从控制台复制到设计初始化程序 ( config/initializers/devise.rb)

config.secret_key = '4fce3c1c860216b8......'
于 2015-07-20T14:58:41.017 回答
0

您需要添加一行来config/initializers/devise.rb设置密钥(将下面的示例值替换为更安全和随机的密钥):

 config.secret_key = 'yoursecretkey'

之后,只需停止 Rails 服务器并重新启动它。另请参阅此Stackoverflow 问题

于 2014-05-15T21:15:12.920 回答