简体   繁体   English

RAILS_ENV和轨道2.3.2

[英]RAILS_ENV and rails 2.3.2

i noted that in rails 2.3.2 there is no more option to set which rails environment you are using. 我注意到在rails 2.3.2中没有更多选项来设置你正在使用的rails环境。 So i cannot just set it anymore in environment.rb? 所以我不能再在environment.rb中设置它了? There is any other way to set it? 有没有其他方法来设置它?

RAILS_ENV=production rake db:migrate

What exactly are you trying to run? 你到底想要跑什么? The rails generator? 轨道发电机? A rake task? 一个耙子任务? Mongrel? 杂种? I'm not sure this is actually a Rails issue. 我不确定这实际上是一个Rails问题。

Disclaimer: I haven't used 2.3.2, however. 免责声明:我没有使用过2.3.2。

im using rails 2.3.5 which should be similar to 2.3.2, and terry lorber is right, 我使用rails 2.3.5应该类似于2.3.2,而terry lorber是对的,

RAILS_ENV=xyz is the exact way to lauch rails stuff with RAILS_ENV specifified from command line. RAILS_ENV = xyz是从命令行指定RAILS_ENV的lauch rails的确切方法。

In this way, you can use rake, script/console script/runner script/server etc. in your different environments 通过这种方式,您可以在不同的环境中使用rake,脚本/控制台脚本/运行脚本/服务器等

Maybe you mean in config/environment.rb ? 也许你的意思是在config/environment.rb

I'm 90% sure you can just add the line there if you need it. 我90%确定你可以在需要的时候在那里添加线。 And I'm wrong , see VP's comment below. 我错了 ,请参阅下面的VP评论。 (Tested and confirmed it) (经过测试并确认)

If you wanna run an application in development, 如果您想在开发中运行应用程序,

ruby script/server

To run in production, 要在生产中运行,

ruby script/server -e production

define in config/environments/production.rb or development.rb or whatever other modes you are running like stage.rb instead of writing/defining in config/environment.rb 在config / environments / production.rb或development.rb中定义或运行的任何其他模式,如stage.rb,而不是在config / environment.rb中编写/定义

I am using it and its serving my purpose. 我正在使用它并满足我的目的。 don't use the keyword RAILS_ENV (I haven't tried it) I am using it APP_MODE = "Production" In production environment file and APP_MODE = "Development" in development file. 不要使用关键字RAILS_ENV(我还没试过)我正在使用它APP_MODE =“生产”在生产环境文件和APP_MODE =开发文件中的“开发”。

then you can use this in your application to detect which mode you are in. 然后您可以在应用程序中使用它来检测您所处的模式。

Hope, I answer the question 希望,我回答这个问题

我认为这是一个命令行参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM