views:

1426

answers:

5

How can I change my RoR app to run in production mode? Is there a config file (environment.rb for example) to do that?

Thank you.

+4  A: 

Change the environment variable RAILS_ENV to production.

mipadi
+3  A: 

If mipadi's suggestion doesn't work, add this to config/environment.rb

# force Rails into production mode when                          
# you don't control web/app server and can't set it the proper way                  
ENV['RAILS_ENV'] ||= 'production'
Pete
Thank you!!! Helped me a lot.
Adler Medrado
+3  A: 

You can also pass the environment to script/server:

$ script/server -e production
foz
+5  A: 

If you're running on Passegner, then the default is to run in production, in your apache conf:

<VirtualHost *:80>
  ServerName application_name.rails.local
  DocumentRoot "/Users/rails/application_name/public"
  RailsEnv production ## This is the default
</VirtualHost>

If you're just running a local server with mongrel or webrick, you can do:

./script/server -e production

or in bash:

RAILS_ENV=production ./script/server

actually overriding the RAILS_ENV constant in the enviornment.rb should probably be your last resort, as it's probably not going to stay set (see another answer I gave on that)

Dan McNevin
A: 

this would now be

rails server -e production

for rails 3 projects.

BandsOnABudget