3 ms·
> These settings should NOT be stored at the file level, it > should be handled by environment flags. I feel this is a > fundamentally broken feature. Accord
by tomphoolery 13y ago
> These settings should NOT be stored at the file level, it
> should be handled by environment flags. I feel this is a
> fundamentally broken feature.
According to https://github.com/rails/rails/blob/master/railties/lib/rails/application.rb#L304 https://github.com/rails/rails/blob/master/railties/lib/rail..., this YAML file is handled like every other YAML by Rails...it's parsed through ERB first.
That means, you can do something like
development:
secret_key_base: <%= ENV['RAILS_SECRET'] %>
And reference it with that `Rails.configuration` business.
With this, you basically get a nice little API for recalling env variables. Pretty neat!
- 1qaz2wsx3edc 13y agoYes, I'm aware, but what was the problem with storing configurations under `Rails.application.config.thing` as ENV['vars']? It just seems like bloated featured.
- xs_kid 13y agoNo everyone likes that approach, some people prefers to save tokens in yaml files (see on github, you will find a dozen o plugins that do same thing)
- 1qaz2wsx3edc 13y agoJust because you can, and others do, doesn't necessarily make it a good idea. By writing & encouraging developers to use the new `secrets` API, we expose them to a bad practise. Not only that, but other solutions exist (like using `Rails.application.config`). I'm not against configuration files per-say, I'm against secrets as persisted values in a codebase. Doing this is bad: https://github.com/search?l=ruby&q=cookie_secret&ref=cmdform&type=Code https://github.com/search?l=ruby&q=cookie_secret&ref=cmdform...
- ds_ 13y agoWouldn't the secrets file be added to gitignore?
- angryasian 13y agoit shouldn't be , because thats where some people will store their keys and others will reference their ENV variables.
- mnarayan01 13y agoPresumably this would be treated just as `config/database.yml` is currently, i.e. `config/secrets.sample.yml` would be committed to the VC while `config/secrets.yml` would be ignored by the VC. When you deployed you would symlink from a shared (private) file to the secrets file.