I need to create a custom config in my app rails to load the configuration url of my services and accessing the configuration in my models.
Thank you.
I need to create a custom config in my app rails to load the configuration url of my services and accessing the configuration in my models.
Thank you.
Create the file you need in your config directory, for example my_config.yml
and populate it with the options you require per environment:
development:
debug_enabled: true
test:
debug_enabled: false
production:
debug_enabled: false
Then create a file called load_config.rb
in your config/initializers directory with this in it:
MY_CONFIG = YAML.load_file("#{Rails.root}/config/my_config.yml")[Rails.env]
Then you can use those settings in your applications like so:
if MY_CONFIG[:debug_enabled]
# ... do something special ...
end