Monday, April 4, 2011

Ruby -=- Using environment variable


With Ruby, You can use environment variable by using the function.


The variable must be defined in the operating system.

Ruby have many places to define environment variable within the code. You can put environment variable common across environment in [RubyProject]/config/environment.rb

Also, if you want to define an environment variable for a specific environment, you can set the variable in [RubyProject]/config/environments/production.rb or test.rb or development.rb...

The variable defined in the project can be use directly. For example, if I put MY_VAR = 3 in the file environment.rb, I will use the variable directly by calling MY_VAR in the code. For example


No comments:

Post a Comment