ArgumentError(生成cookie会话数据的完整性哈希需要一个秘密

运行rails应用程序时出现此错误,这是完整的错误

ArgumentError(生成cookie会话数据的完整性哈希需要密码。在config / initializers / secret_token.rb中使用config.secret_token =“至少30个字符的一些秘密短语”): **

我使用rvm 1.9.3和rails 3.2.13。

任何帮助赞赏。

提前致谢。

这条消息很简单。 检查config/initializers/secret_token.rb文件中的config.secret_token设置,如果不存在则配置它。

使用以下方法生成秘密令牌

 rake secret 

它会回来

 => '3eb6db5a9026c547c72708438d496d942e976b252138db7e4e0ee5edd7539457d3ed0fa02ee5e7179420ce5290462018591adaf5f42adcf855da04877827def2' 

然后编辑您的文件或创建一个新文件:

 # config/initializers/secret_token.rb # Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. MyApp::Application.config.secret_token = '3eb6db5a9026c547c72708438d496d942e976b252138db7e4e0ee5edd7539457d3ed0fa02ee5e7179420ce5290462018591adaf5f42adcf855da04877827def2' 

当我使用figaro gem来保密我的密钥时,我遇到了这个问题。

如果将项目克隆到新位置,application.yml将不存在。 这是理想的行为,因为我们不希望更广泛的互联网能够检查我们所有的秘密信息。

如果这是你的问题。 您需要从其原始位置复制application.yml,或生成新密钥以替换那里的那些密钥。

是。 字符串是对的:

 config.secret_token = "..." 

但是,对我来说 – 在将此字符串放入config/application.rb文件后,redmine可以飞行。