Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 我能';t获取rails中setting.yml的refile.rb值_Ruby On Rails_Rspec_Refile - Fatal编程技术网

Ruby on rails 我能';t获取rails中setting.yml的refile.rb值

Ruby on rails 我能';t获取rails中setting.yml的refile.rb值,ruby-on-rails,rspec,refile,Ruby On Rails,Rspec,Refile,我想调用config/initializers/refile.rb中setting.yml的值 所以我试着设置如下,但它并没有像我想的那样工作 运行SPEC文件时,Refile.cdn_host的值为空。 我不知道为什么这个值是空的。 我能得到一些建议吗 config/settings/test.yml cloudfront: host: 'localhost' config/initializers/refile.rb Refile.cdn_host = Settings.cloudfro

我想调用config/initializers/refile.rb中setting.yml的值 所以我试着设置如下,但它并没有像我想的那样工作

运行SPEC文件时,Refile.cdn_host的值为空。 我不知道为什么这个值是空的。 我能得到一些建议吗

config/settings/test.yml

cloudfront:
 host: 'localhost'
config/initializers/refile.rb

Refile.cdn_host = Settings.cloudfront.host
顺便说一下,当我改变它如下

Refile.cdn_host = 'localhost'

它不为空就可以工作。

您需要先加载文件,然后重试

Refile.cdn_host = YAML.load_file("#{Rails.root.to_s}/config/settings/test.yml")['cloudfront']['host']