Rails Quick Tip: Set a secret token for Heroku deploy

Rails apps use a secret token to keep user information save, so the more entropy the better. This means using the same secret token on heroku and locally is not ideal, and quite easy to fix.

First make the secret_token.rb set the token from an ENV variable

MyApp::Application.config.secret_key_base = ENV['SECRET_KEY_BASE'] || "sometoken"

And now create the token in the heroku config

heroku config:set SECRET_KEY_BASE=`rake secret`

That’s it, enjoy!