How to set RAILS_ENV for different directories (fcgid)

Hello!

I want to use the same application in two environments (production and development) on the same server (apache2 with fcgid) in different (aliased) directories.

Is there a way to specify RAILS_ENV inside my <Directory> directives? I have the line DefaultInitEnv RAILS_ENV production in my httpd.conf but I want one of the directories to be development.

Setting the ENV var directly in environment.rb is not an option because I update the production server via SVN but need to keep environment.rb in my repository.

Hi,

I had the same problem. Unfortunately my solution was to change the environment.rb for the production app.

In Apache I have two virtual hosts, and I put the following in the staging defination :

SetEnv RAILS_ENV development

and in the production host I put :

SetEnv RAILS_ENV production

But for some reason that does not work. Maybe someone can tell us why this solution does not work.

Kind Regards Hamza

Hello!

I want to use the same application in two environments (production and development) on the same server (apache2 with fcgid) in different (aliased) directories.

Is there a way to specify RAILS_ENV inside my <Directory> directives? I have the line DefaultInitEnv RAILS_ENV production in my httpd.conf but I want one of the directories to be development.

Setting the ENV var directly in environment.rb is not an option because I update the production server via SVN but need to keep environment.rb in my repository.

You could make the enviroment.rb more dynamic, i.e. compute the value for RAILS_ENV from the current path. A hack but all ruby:

RAILS_ENV = case `hostname`.chomp
            when "myserver": /myproduction_dir/.match(File.expand_path(RAILS_ROOT)) ? 'production' : 'development             else 'development'             end

Or something along these lines.

zsombor