I added the Devise gem then followed the instructions and ran rails generate devise:install
, the result was the following:
我添加了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.
How do I 'restart' my application? And how and where do I set the secret key?
如何“重启”我的申请?我如何以及在何处设置密钥?
2 个解决方案
#1
13
In order to generate a secret run:
为了生成秘密运行:
bundle exec rake secret
and copy the result from the console to the devise initializer (config/initializers/devise.rb
)
并将结果从控制台复制到设计初始化程序(config / initializers / devise.rb)
config.secret_key = '4fce3c1c860216b8......'
#2
1
You need to add a line to your config/initializers/devise.rb
to set the secret key (replace the example value below with a more secure and random key):
您需要在config / initializers / devise.rb中添加一行来设置密钥(使用更安全的随机密钥替换下面的示例值):
config.secret_key = 'yoursecretkey'
After that just stop your Rails server and start it again. Also see this * question.
之后,只需停止Rails服务器并再次启动它。另请参阅此*问题。
#1
13
In order to generate a secret run:
为了生成秘密运行:
bundle exec rake secret
and copy the result from the console to the devise initializer (config/initializers/devise.rb
)
并将结果从控制台复制到设计初始化程序(config / initializers / devise.rb)
config.secret_key = '4fce3c1c860216b8......'
#2
1
You need to add a line to your config/initializers/devise.rb
to set the secret key (replace the example value below with a more secure and random key):
您需要在config / initializers / devise.rb中添加一行来设置密钥(使用更安全的随机密钥替换下面的示例值):
config.secret_key = 'yoursecretkey'
After that just stop your Rails server and start it again. Also see this * question.
之后,只需停止Rails服务器并再次启动它。另请参阅此*问题。