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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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?

Thanks,

Brian

--
www.kenlet.com
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
that:

script/server -e production

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

#!/bin/sh
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.