开发者

How can I set RAILS_ENV to production for all subsequent rake commands?

开发者 https://www.devze.com 2023-01-04 21:07 出处:网络
As a bonus how do I s开发者_高级运维et this in a config, so that when I log into my production server I don\'t have to retype it.in your .bashrc, put:

As a bonus how do I s开发者_高级运维et this in a config, so that when I log into my production server I don't have to retype it.


in your .bashrc, put:

if [[ $- != *i* ]] ; then
    # Shell is non-interactive.  Be done now!
    return
fi

export RAILS_ENV=production

Be careful, you will always be in production mode when you login !


I tend to want to set it conscientiously with each command also.

Although I don't do much directly on the server, I'm usually using capistrano. So if I was working directly on the server a lot, I might want to set it permanently. Which, BTW, Larry didn't mention how to do:

$ RAILS_ENV=production
$ rake foo
$ rake bar


I use

rake task_name RAILS_ENV=production

That way I have to type the phrase "production" conscientiously. Fewer booboos!

Bonus answer:

Set the environment variable RAILS_ENV to production.

You can do that as a shell alias. Eg "set_production" Exact syntax depends on your shell type.

Or you can set the env variable when you login on the production system.

0

精彩评论

暂无评论...
验证码 换一张
取 消