Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails : deploying first app - production mode

I am very confused about this whole rails deploy thing. The confusion is that whilst developing the whole app it has been in development mode, which is fine. Now that I will deploy it, are there ammendments I need to make to files to change the rails app to production mode before deploying, or does deploying autmatically do this?

I guess what I am asking is how do I switch from one environment to another?

like image 944
Muhammed Bhikha Avatar asked Aug 31 '25 02:08

Muhammed Bhikha


2 Answers

No need to change any files just set shell variable RAILS_ENV=production on your server

like image 183
Anatoliy Kukul Avatar answered Sep 02 '25 15:09

Anatoliy Kukul


rails server -e production will put you in production mode.

ALSO...

By default rails 3.1 and later defer assets to the asset pipeline. So you either need to run rake assets:precompile or turn on serving assets in config/environments/production.rb.

# config/environments/production.rb
config.assets.compile = true

You also need to ensure that your production database is setup correctly in config/database.yml

Other than that you are good to go :)

If this is truly a production box you could also set an environment variable to 'production' as well. As explained by Anatoliy Kukul in another answer.

like image 32
mwoods79 Avatar answered Sep 02 '25 17:09

mwoods79