Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx/Passenger/Rails, where to set RAILS_ENV?

I've deployed my site to its testing location, but I'm not sure where I set what the RAILS_ENV should be for this server. Where should I look?

like image 672
Josh M. Avatar asked Sep 29 '13 22:09

Josh M.


People also ask

Where is Rails_env defined?

RAILS_ENV is just an environmental variable which is set in the shell or the operating system itself (or when invoking the process). Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs.

How does rails ENV get set?

The ENV hash in your Rails application is set when your Rails application starts. Rails loads into ENV any environment variables stored in your computer and any other key-value pairs you add using Figaro gem.


2 Answers

Short Answer: passenger_app_env development;

Sets: RAILS_ENV RACK_ENV WSGI_ENV NODE_ENV PASSENGER_APP_ENV

Example nginx conf:

    http {
    passenger_root /home/user/.rvm/gems/ruby-2.1.0@app/gems/passenger-4.0.29;
    passenger_ruby /home/user/.rvm/wrappers/ruby-2.1.0@app/ruby;
    passenger_app_env development;
}
like image 128
Abs Avatar answered Oct 23 '22 21:10

Abs


You can use rack_env directive to set the rails env as described here in passenger for nginx documentation

6.16. Rack and Rails >= 3 specific options

If you are on rails 1.x or 2.x, you can use rails_env directive

like image 29
Litmus Avatar answered Oct 23 '22 20:10

Litmus