質問

I am setting the below environment variable.

ENV["RAILS_RELATIVE_URL_ROOT"] = "/prefix"

Is there any way of accessing this env variable other than ENV["RAILS_RELATIVE_URL_ROOT"]? I know rails env can be accesses like Rails.env. Can all the env variables be accesses like that or is it something special for rails_env?

役に立ちましたか?

解決

Rails.env only gives you the value of ENV["RAILS_ENV"] or ENV["RACK_ENV"]. If none of them were set, it returns "development".

The ENV object is provided by Ruby.

For another way to access it, you might consider either implementing it by yourself, or using the figaro gem. Set environment variables in a YAML config. Then they can be accessed like this:

Figaro.env.rails_relative_url_root
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top