2012-02-03 53 views
0

我看到一些奇怪的行为,当我运行Rails服务器rails s -e [env](双**添加了强调):什么能导致`rails s`忽略-e开关?

~/app> rails s -e=**production**# << ok...v 
=> Booting Mongrel    #   v huh? 
=> Rails 3.1.1 application starting in **test** on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
^CExiting 
~/app> rails s -e=**development** 
=> Booting Mongrel 
=> Rails 3.1.1 application starting in **test** on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
^CExiting 
~/app> RAILS_ENV=**development** rails s 
=> Booting Mongrel 
=> Rails 3.1.1 application starting in **development** on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
^CExiting 
~/app> RAILS_ENV=**production** rails s 
=> Booting Mongrel 
=> Rails 3.1.1 application starting in **production** on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 

其结果是,-e开关被忽略。

的没有提到在那里将被覆盖的任何情况。命令行帮助说-e Specifies the environment to run this server under test/development/production).好的。

我真的认为这是几个星期前,做工精细(已经有一段时间了,我开始上那箱督促服务器),所以我可能已经改变的东西,打破了这一点,但什么?我检查了我在那里用=代替==,但没有发现任何地方。不要认为这将解释这一点。

更新:约翰正确地指出它是-e [env]。我首先尝试了相同的结果,然后尝试-e=[env]。正确的方法(仍然会产生不正确的结果):

~/app> rails s -e production -p 5000 
=> Booting Mongrel ^^^^^^^^^   vvvv 
=> Rails 3.1.1 application starting in test on http://0.0.0.0:5000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
+1

这是奇怪的是,在它自己的运行轨道小号带来了测试环境,而不是发展,就是默认行为。你可以尝试设置RAILS_ENV环境变量,这是普遍尊重整个轨道,并看看会发生什么:'$ RAILS_ENV =生产钢轨s' – 2012-02-03 22:30:07

回答

1

检查你没有RAILS_ENV环境变量设置为任何你传递的命令行选项,它会覆盖。

rails source ydoes这

ENV["RAILS_ENV"] ||= options[:environment] 

options从命令行参数填充的相关位,所以如果RAILS_ENV已经设置您的命令行选项没有任何效果。

+0

啊,看起来这是答案。不知道,谢谢。我*会*设置RAILS_ENV来模仿制作。 – jcollum 2012-02-04 18:14:09

0

rails s -e <env>,不rails s -e=<env>。注意与环境的名称-e之间的空间:

#Ψ rails s -e production 
#=> Booting WEBrick      vvvvvvvvvv 
#=> Rails 3.1.1 application starting in production on http://0.0.0.0:3000 
             ^^^^^^^^^^ 
#Ψ rails s -e staging 
#=> Booting WEBrick      vvvvvvv 
#=> Rails 3.1.1 application starting in staging on http://0.0.0.0:3000 
             ^^^^^^^ 
+0

我想,也具有相同的结果。将更新操作。 – jcollum 2012-02-03 21:23:13

+0

你能链接到一个有你的代码的仓库吗? – 2012-02-03 21:27:55

+0

0_o全部都是?这是IP保护的后盾,所以我无法分享。 – jcollum 2012-02-03 21:29:28

相关问题