Forum: Ruby on Rails Setting RAILS_ENV before running script/server in the comma

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Brian L. (Guest)
on 2006-02-10 21:07
(Received via mailing list)
I want to set an environment variable before running a script

for example setting

 ENV['RAILS_ENV'] = production

in the command line before running script/server so that it would
start in production mode.

Is there a way to do this from the command line so that I don't have
to modify the file?



Francois B. (Guest)
on 2006-02-10 21:15
(Received via mailing list)
Hi !

2006/2/10, Brian L. <removed_email_address@domain.invalid>:
>  ENV['RAILS_ENV'] = production

If that is all you want to do, script/server has an option to do just

script/server -e production

On the other hand, if you want to set other environment variables, you
might want to create a launcher script:

export SOME_VAR=123
export VAR2=/var/db/root

cd /var/www/app1
script/server -e production

If you're on Windows, the same can be done, albeit slightly differently.

Hope that helps !
This topic is locked and can not be replied to.