How can I define the environment when restarting 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With