Using Secrets.yml File In Rails 4.1+

Posted by Weston Ganger on May 13, 2015

I was running brakeman (a rails security scanner) and it was complaining about a secret_token in config/initializers/secret_token.rb. So I looked into the secrets.yml file and heres how it works.

For example I am going to show how to setup the secret_key_base.

# config/secrets.yml

  secret_key_base: your_super_long_secret_key

To use this value you would use ‘Rails.application.secrets.secret_key_base’

Now to setup this value in your config/initializers/secret_token.rb:

# config/initializers/secret_token.rb.yml

YourAppName::Application.config.secret_key_base = Rails.application.secrets.secret_key_base

Related External Links:

Posted in Rails and Tagged with secrets.yml rails secret_token 

Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts