As a bonus how do I set this in a config, so that when I log into my production server I don't have to retype it.
A:
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.
Larry K
2010-06-24 21:01:52
+2
A:
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
John
2010-06-24 23:10:48
A:
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 !
Nicolas Viennot
2010-06-24 23:15:24