rails_env not working, apparently

689 views
Skip to first unread message

Leandro N. Camargo

unread,
Nov 9, 2009, 2:10:36 PM11/9/09
to Phusion Passenger Discussions
Well, everything is running fine with nginx and passenger on my
server.
The only problem is that I realized my rails app is not running as a
'staging' environment.

I put the "rails_env staging;" inside my server { } block and it
still runs as 'production' environment.

Any guess on this?

Thanks.

Elliot Temple

unread,
Nov 24, 2009, 2:13:44 PM11/24/09
to Phusion Passenger Discussions
I am having the same problem. rails_env line is ignored.

I just installed passenger with nginx on snow leopard. I previously
had it working on PPC leopard, so I think my config file is good. On
the old computer I had passenger 2.2.4. Now I've got 2.2.7. I've got:

server {
listen 80;
server_name secrethostname.local;
root /Users/curi/stuff/public; # <--- be sure to point to
'public'!
passenger_enabled on;
rails_env development;
}

The only lines changed from my previous working config were:

passenger_root /Library/Ruby/Gems/1.8/gems/passenger-2.2.7/;
passenger_ruby /usr/bin/ruby;

and

user curi staff;

I had to specify the "staff" group instead of leaving group
unspecified. Looked like my old computer had a group named after my
username, which was being used by default, and now snow leopard
doesn't have that.

So, it ignores the rails_env line and tries to connect to the
production database server. Any help?

Elliot Temple

unread,
Nov 24, 2009, 2:27:39 PM11/24/09
to Phusion Passenger Discussions


On Nov 9, 11:10 am, "Leandro N. Camargo" <leandro...@gmail.com> wrote:
> Well, everything is running fine with nginx and passenger on my
> server.
> The only problem is that I realized my rails app is not running as a
> 'staging' environment.
>
> I put the "rails_envstaging;" inside my server {  } block and it
> still runs as 'production' environment.
>
> Any guess on this?

I wrote a reply with the same problem that doesn't seem to have
appeared yet. But anyway I found a fix. Add this at the top of your
config.ru

ENV['RAILS_ENV'] = ENV['RACK_ENV'] if !ENV['RAILS_ENV'] && ENV
['RACK_ENV']

If anyone knows a better way, please let me know!
Reply all
Reply to author
Forward
0 new messages