I can't get the value of refile.rb fron setting.yml in rails

32 Views Asked by At

I would like to call value of setting.yml in config/initializers/refile.rb So I try to set it as follows.But it Does not work as I thought.

When I run SPEC file, the value of Refile.cdn_host is empty. I don't know well why this value is empty. can I get some advice?

config/settings/test.yml

cloudfront:
 host: 'localhost'

config/initializers/refile.rb

Refile.cdn_host = Settings.cloudfront.host

Incidentally when I change it as follows,

Refile.cdn_host = 'localhost'

it does work without being empty.

1

There are 1 best solutions below

0
Md. Farhan Memon On

You need to load the file first, try

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