Rails load YAML to hash and reference by symbol

前端 未结 11 2052
慢半拍i
慢半拍i 2021-02-01 12:22

I am loading a YAML file in Rails 3.0.9 like this:

APP_CONFIG = YAML.load(File.read(File.expand_path(\'../app.yml\', __FILE__)))

It loads the a

11条回答
  •  醉话见心
    2021-02-01 12:24

    Try using the HashWithIndifferentAccess like

    APP_CONFIG = HashWithIndifferentAccess.new(YAML.load(File.read(File.expand_path('../app.yml', __FILE__))))
    

提交回复
热议问题