Ruby on Rails config.secret_token error

前端 未结 6 977
-上瘾入骨i
-上瘾入骨i 2021-02-04 13:33

I just started learning ruby on rails. I followed a lot of install examples, but when i ran the example am getting this error

A secret is required to generate an integri

6条回答
  •  失恋的感觉
    2021-02-04 13:58

    Your token should have been generated automatically by Rails, but you could still use something like:

    irb(main):007:0> "#{ActiveSupport::SecureRandom.hex(64)}"
    => "921b00fcfabe0368d70627020f3b4c969cfd9bdc2474f4040c1ae976f687014694beb5d36dfc0c41bac8ebde96a14fceaee228d6e34d8183c5d7cc99d310d4f9"
    

    meaning, you can generate some random string and put it into your config/initializers/secret_token.rb file:

    # Be sure to restart your server when you modify this file.
    
    Yourapp::Application.config.secret_token = '921b00fcfabe0368d70627020f3b4c969cfd9bdc2474f4040c1ae976f687014694beb5d36dfc0c41bac8ebde96a14fceaee228d6e34d8183c5d7cc99d310d4f9'
    

提交回复
热议问题