How can I set the RAILS_ENV in a Windows console?

泄露秘密 提交于 2019-12-10 02:16:03

问题


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

How can I do the equivalent if I'm running the task on Windows XP in a Windows console?


回答1:


c:>set RAILS_ENV=monster_island

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.

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).




回答2:


Of course you can use 'setX' (instead of simply 'set' if you want the variable to persist between console sessions (and you don't want to navigate through the various screens/tabs in the Control Panel



来源:https://stackoverflow.com/questions/1007589/how-can-i-set-the-rails-env-in-a-windows-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!