How to determine the environment when you restart the Rails application from the command line?

How can I determine the environment when I restart the Rails application from the command line?

+6
source share
2 answers

if you had in mind how to specify rails, which environment loads when the server starts from the command line, here's how:

rails server -e production 
+13
source

In general, Rails gets its environment from the shell variable RAILS_ENV at startup or defaults to "development". You can specify the environment for the rails command, for example rails server , rails console (Rails 3), script/server or script/console (Rails 2.x) from the bash command line, as shown below:

 RAILS_ENV=something rails s 

This means that for the rails s variable, the value "something" is assigned to the variable RAILS_ENV .

+8
source

Source: https://habr.com/ru/post/885593/


All Articles