Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I define the environment when restarting a Rails app from the command line?

How can I define the environment when restarting a Rails app from the command line?

like image 634
xiatica Avatar asked Apr 10 '11 05:04

xiatica


2 Answers

if you meant how to tell rails which environment to load when you start the server from command line, here's how:

rails server -e production
like image 79
Andrei S Avatar answered Oct 22 '22 16:10

Andrei S


In general, Rails gets its environment from the RAILS_ENV shell variable at start-up, or defaults to "development". You can specify an environment for a rails command such as rails server, rails console (Rails 3), script/server or script/console (Rails 2.x) from the bash command line as follows...

RAILS_ENV=something rails s

This means to set the RAILS_ENV environment variable to "something" for the execution of the rails s command.

like image 10
Steve Jorgensen Avatar answered Oct 22 '22 18:10

Steve Jorgensen