Rails

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

production:
  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 


Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts