Reputation: 20648
I have placed all of my custom configurations from application.rb to initializers/batch.rb file and the configuration look likes this
Batch.enc_sys = "utf"
from a file which I have used in Models directory how do I read the above value? I could not read them like the way I read values which declared in application.rb
Can anyone help?
Upvotes: 1
Views: 594
Reputation: 5111
The other way (RAILS way) would be make a config.yml file within the config directory like this
defaults: &defaults
batch:
enc_sys: utf8
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults
This configuration file gets loaded from a custom initializer in config/initializers:
APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[RAILS_ENV]
You can then get the value like:
APP_CONFIG["batch"]['enc_sys']
Upvotes: 2