开发者

Rails 3 - set environment

开发者 https://www.devze.com 2023-01-19 16:57 出处:网络
I have a rails 3 app (which I upgraded). It runs on passenger and nginx but on my production server it also starts with the environment set to \'production\'. I know I am missing something really basi

I have a rails 3 app (which I upgraded). It runs on passenger and nginx but on my production server it also starts with the environment set to 'production'. I know I am missing something really basic, but I just can't figure out where to set the environment instead of in environment.rb.

Thanks for helping!

UPDATE: ok, I learned I can still do that with Rails.env = 'production'.

That seems kind of old school to me. Do you know an elegant way to configure this maybe i开发者_如何学Gon the Capfile or sth like that?


Rails 3 is a little bit different than Rails 2.x in that it has a config.ru file, like other Rack applications.

Passenger detects rails as a Rack app, so you'll have to use RackEnv instead of RailsEnv in the vhost. You can set the environment using RackEnv as per the documentation for Passenger/Nginx.


You can configure a different RAILS_ENV for each app in your vhost for nginx with passenger. I've never used nginx but in apache it's just a RailsEnv=development directive. That way each site just has it set, no worries with configuring a cap task or variable or anything. See the docs. Note that the default is production so this should already be set for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消