How can I define the environment when restarting a Rails app from the command line?
如何从命令行重新启动Rails应用程序时定义环境?
2 个解决方案
#1
13
if you meant how to tell rails which environment to load when you start the server from command line, here's how:
如果您的意思是如何告诉rails从命令行启动服务器时要加载哪个环境,请按以下步骤操作:
rails server -e production
#2
10
In general, Rails gets its environment from the RAILS_ENV shell variable at start-up, or defaults to "development". You can specify an environment for a rails command such as rails server
, rails console
(Rails 3), script/server
or script/console
(Rails 2.x) from the bash command line as follows...
通常,Rails在启动时从RAILS_ENV shell变量获取其环境,或者默认为“development”。您可以从bash命令行为rails命令指定环境,例如rails服务器,rails控制台(Rails 3),脚本/服务器或脚本/控制台(Rails 2.x),如下所示...
RAILS_ENV=something rails s
This means to set the RAILS_ENV
environment variable to "something" for the execution of the rails s
command.
这意味着将RAILS_ENV环境变量设置为“某事”以执行rails s命令。
#1
13
if you meant how to tell rails which environment to load when you start the server from command line, here's how:
如果您的意思是如何告诉rails从命令行启动服务器时要加载哪个环境,请按以下步骤操作:
rails server -e production
#2
10
In general, Rails gets its environment from the RAILS_ENV shell variable at start-up, or defaults to "development". You can specify an environment for a rails command such as rails server
, rails console
(Rails 3), script/server
or script/console
(Rails 2.x) from the bash command line as follows...
通常,Rails在启动时从RAILS_ENV shell变量获取其环境,或者默认为“development”。您可以从bash命令行为rails命令指定环境,例如rails服务器,rails控制台(Rails 3),脚本/服务器或脚本/控制台(Rails 2.x),如下所示...
RAILS_ENV=something rails s
This means to set the RAILS_ENV
environment variable to "something" for the execution of the rails s
command.
这意味着将RAILS_ENV环境变量设置为“某事”以执行rails s命令。