I have some configuration values in a YAML file that needs loaded when my app starts up. The values need to be accessed in a few different places (both in a few models and a few controllers). What is the best way to load, store, and access these?
You can do as follows
create file yml example test.yml :
key: 936QQ84d3c4m8Y4Y
create file in config/initializers.
test = YAML.load_file("#{RAILS_ROOT}/config/test.yml")
KEY = test["key"]
An initializer. John Nunemaker posted the one he uses for Harmony over on gist.
So in that example harmony.rb would go in config/initializers and harmony.yml would just be in config.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With