如何在 Windows 控制台中设置 RAILS_ENV? [英] How can I set the RAILS_ENV in a Windows console?
问题描述
在 Linux 和 OS X 上,我习惯于通过这样做在指定的 Rails环境"中运行 Rake 任务:
On Linux and OS X, I'm accustomed to running Rake tasks in specified Rails "environments" by doing this:
$ export RAILS_ENV=monster_island ; rake monsters:destroy_all
如果我在 Windows XP 上的 Windows 控制台中运行任务,我如何执行等效操作?
How can I do the equivalent if I'm running the task on Windows XP in a Windows console?
推荐答案
c:>set RAILS_ENV=monster_island
c:>set RAILS_ENV=monster_island
如果不带任何其他参数运行 set,您将看到设置的环境变量.在控制台中运行 set 将仅为该控制台设置该变量,并且不会跨会话或其他控制台持久存在.
If you run set without any other arguments, you will see the environment variables that are set. Running set in a console will set that variable for just that console and won't be persisted across sessions or to other consoles.
您也可以在控制面板中永久设置 - 打开系统,选择高级,然后选择环境变量(这可能会因您的 Windows 版本而略有不同).
You can also set it permanently in the Control Panel - open System, select Advanced, and then Environment Variables (this may vary slightly depending on your version of Windows).
这篇关于如何在 Windows 控制台中设置 RAILS_ENV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!