Rails configuration: settings and files

The following mechanisms are used to configure runtime settings for the chf-sufia application.

Configuration .yml files

Don't use this method for new code, but a dozen or so .yml config files can be found in the config directory. These are loaded in the code (typically by gems).

CHF::ENV

For permanent configuration, we use the CHF::Env class . This is defined (and documented in more detail) in the lib/chf/env.rb file.

Values are taken from, in priority order:
 * The Unix environment varialble (ENV) if present -- uppercased. ENV['FOO_BAR'] for key 'foo_bar'.
 * The config/local_env.yml file if present and has key. This file is supplied by ansible with level/role-specific values, or might be created by hand in dev if convenient.
 * Defaults are configured in lib/chf/env.rb.

These settings are not easily changed at runtime, so use this for settings that will never change after the program is launched. (We sometimes work around this in tests involving mocking.)

Rails.application.config

Settings that differ between dev, test and production instances can also be set in the Rails.application.config files, namely

config/application.rb (defaults)
config/environments/development.rb
config/environments/test.rb
config/environments/production.rb

Settings can be looked up at runtime

by invoking the Rails.application.config object. (see https://guides.rubyonrails.org/configuring.html for more details).

Always set a default in application.rb if you want to override it in one of the three other files.