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