[1] http://biggestfool.tumblr.com/post/24049554541/reminder-secr...
[1] http://biggestfool.tumblr.com/post/24049554541/reminder-secr...
My ideal solution will probably be to:
1) Look for an environment variable
2) Look for a file in the project config or root named: secret-git-ignore-this-file (or something similar)
3) If it fails to find either of then generate a new secret with secure_rand
4) If running on Heroku write it to the environment variable (I think this can be done and should persist although I'll need to check the documentation).
5) Otherwise write it to the secret-git-ignore-this-file
If/when I get round to this I'll probably try to put it on Github for others to use although if anyone knows of any good published solutions that do something like this that would be even better.
Basically it adds a yml file, that is added to .gitignore, with configuration settings that get added to ENV. It can even send your environment variables to Heroku using a Rake task. There are some examples on the page. You can use it to have different secret keys depending on your Rails environment as well.
Such approach is simply not scalable. I don't know what secret_token.rb is (I do Python) but if it's anything like an HMAC key for encrypting your session cookies, your app will break once deployed to more than one frontend because the cookies will suddenly become tied to specific dyno.
You run the app locally using foreman, store your local variables in a .env file, and add that to your gitignore.
For your heroku running app, you use the toolbelt to add env variables.
https://devcenter.heroku.com/articles/config-vars#local-setu...
https://devcenter.heroku.com/articles/config-vars#setting-up...
I can rethink the solution if I need scale. I don't really think of it as config as I don't care what the value is just that it is consistent on any given host.