how to set an Environment variable from command line.

Hello,

I am looking to set a Variable from the command line during starting up my server that will be accessible to the whole ruby on rails application.

One way of setting such a config variable was putting defining it into the environment.rb file but then I don't know if I could override the value of this variable in the environment.rb file when I start up my server from the command line.

Thanks Philip

Hi,

You can write this in environment file:

SOME_CONSTANT = ENV[“SOME_CONSTANT”] || “A DEFAULT VALUE”

then start rails by

SOME_CONSTANT=“42” script/server

or it will use default value.

Jan