Passenger (mod_rails) and RAILS_ENV

software development



Is there any way to specify the RAILS_ENV when using Passenger? I tried setting it in my environment.rb, but it doesn’t look like it takes anything other than “production”


Figured it out… setting the RAILS_ENV constant instead of the ENV[‘RAILS_ENV’] did the trick.


I cam up with a way to set Rails_env differently depending on the capistrano stage being deployed to, in case it’s helpful.


This is great. I am having the same issue. It looks like you have the right answer. But how did you set RAILS_ENV instead of ENV[‘RAILS_ENV’]. I can’t figure it out.


I just ran into this myself and found another alternative: you can set Passenger’s RAILS_ENV in your .htaccess file (e.g. in /home/username/yourdomaindir/.htaccess):

RailsEnv development
After that, restart your passenger instance:

touch /home/username/yourdomaindir/tmp/restart.txt
What I like about this is that you don’t have change environment.rb. (I deploy from svn and don’t like server-modified files). Though you also have to remember to set the right environment when you rake:

export RAILS_ENV=development rake db:migrate

I’m a RoR newbie, though, so if there’s a good reason not to do this please let me know.