How can I define the environment when restartin开发者_运维百科g a Rails app from the command line?
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
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.
精彩评论