测试 执行 Rspec 时提示 “You didn't set config.secret_key_base.”

johnlu · 2013年08月01日 · 最后由 JohnLu 回复于 2013年08月01日 · 4371 次阅读

执行rspec spec/requests/authentication_pages_spec.rb -e "signin with invalid information"

提示: ·DEPRECATION WARNING: You didn't set config.secret_key_base. Read the upgrade documentation to learn more about this new config option. (called from get at /home/johnlu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/forwardable.rb:171)

在网上找到的解决办法: https://github.com/rails-api/rails-api/issues/72config/application.rb中加入config.secret_key_base = 'blipblapblup'

http://edgeguides.rubyonrails.org/configuring.html有说明,但不懂是什么意思! config.secret_key_base used for specifying a key which allows sessions for the application to be verified against a known secure key to prevent tampering. Applications get config.secret_key_base initialized to a random key in config/initializers/secret_token.rb.

问题是解决了,但迷茫的是为什么要这样设置?

#1 楼 @Rei 谢谢,英文只好硬着头皮看了!

#2 楼 @JohnLu 其实很简单,Rails 4 的 session cookies 储存方式有了变化,需要设置新的 secret_key_base。

顶楼设的那串太短了,rake secret 随机一个长的。

#3 楼 @Rei 谢谢指点,我要努力学英语!!!!!

需要 登录 后方可回复, 如果你还没有账号请 注册新账号