-
Notifications
You must be signed in to change notification settings - Fork 32
AppConfig
AppConfig is a class which has attributes loaded automatically from the config/application.yml file.
If you add your own key/value pairs to application.yml, then you can just call the key as a method on AppConfig.
For example:
Inside config/application.yml:
app_site: http://example.com
AppConfig.app_site #=> "http://example.com"
You can also call the method with a question mark, if you don’t want a method_missing error if the config value is not set.
As well as reading configuration variables, you can set them. When the app closes down, the data is marshalled to disk – and reloaded whenever the app starts up again. For example:
AppConfig.app_site = "http://google.com"
AppConfig.app_site #=> "http://google.com"
So, in the above example, app_site has been overridden – and now will always return “http://google.com”.