Avoid Typing RAILS_ENV All The Time
I often log into my staging or production servers to run a Rake task or fire up the Rails console. I got fed up long ago with specifying the environment in every command. For example:
$ rake --trace db:migrate:redo RAILS_ENV=production
$ script/console production
$ rake ts:in RAILS_ENV=production
It just occurred to me to set the environment variable in, er, the environment (~/.bashrc):
export RAILS_ENV=production
And now I can log in and type simply what I want to type:
$ rake --trace db:migrate:redo
$ script/console
$ rake ts:in
I am so embarrassed that I didn’t think of this three years ago.
Andy Stewart, 10 April 2009
Posted in Deployment, Rails, Ruby

0 Comments
Jump to comment form