Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch environment in Rails 3?

How can one switch environment in Rails 3?

like image 745
never_had_a_name Avatar asked Aug 14 '10 21:08

never_had_a_name


People also ask

What is the default Rails environment?

Rails ships with a default configuration for the three most common environments that all applications need: test, development, and production.

How do I see environment variables in rails?

Use command ENV in rails console. That will return a hash of your environmental values you can access. Alternatively, you can access your environmental variables from your apps root path using the same command and the variables will be returned formatted.


2 Answers

Use the environment flag:

rails s --environment=production

Or set the RAILS_ENV environment variable.

like image 173
jdeseno Avatar answered Oct 02 '22 11:10

jdeseno


If you want to save keystrokes:

rails s -e production
like image 21
TerryS Avatar answered Oct 02 '22 11:10

TerryS