views:

465

answers:

3

Hi there, Our host does not allow us to modify the passenger config file (i.e. the apache config OR the vhosts file), but we'd like to run rails in dev mode. So we have to specify the environment (prod/dev/test) in one of the files that rails loads AS the application is restarted. Anyone know how to do this?

We've tried the following with no luck:

#environment.rb (before any other code is executed)
  `RAILS_ENV=development`          # using back ticks
  ENV['RAILS_ENV'] = 'development' # assigning to a constant
  RAILS_ENV='development'          # as suggested by one of the answers, unfortunately does not work.
+2  A: 

Setting it right at the top of environment.rb with:

RAILS_ENV = 'development'

should do it. It's possible that passenger overrides this, though.

If you don't have access to the passenger config but you do have access to your virtual hosts then you can also just force it in there with:

RailsEnv development
thenduks
Valiant attempt, but no dice, unfortunately. And I fixed the question so that it's clear that we also do not have access to the vhosts file.
btelles
+4  A: 

Why don't you change your production.rb config to match the settings found in development.rb?

jonnii
This should do it. There's nothing magical about "production" as a name. Swapping all the setting (don't forget the config/environments/production.rb file) should do it.
edebill
Eggsellente...I didn't do that initially because...um...I suffer from ...tunnel vision?
btelles
Happy to help =)
jonnii
+1  A: 

In envriornment.rb you could add:

RAILS_ENV="production"
RAILS_ENV.freeze

That way when it tries to get reset later, it will fail.

I'm not sure what other ramifications this will have later or if it will permeate everywhere within rails.

Dan McNevin