Rails load YAML to hash and reference by symbol

前端 未结 11 2051
慢半拍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:44

    This is the same from the selected answer, but with a better syntax:

    YAML.load(File.read(file_path)).with_indifferent_access 
    

提交回复
热议问题