Running local server as production server

Rails doesn’t serve static assets in production mode by default. If you want to disable this and serve the static assets, update your config/environments/production.rb file with this:

config.serve_static_assets = true

The reasoning behind Rails’ default configuration is that it assumes you’ll be running behind a standard web server in production mode (Apache, Nginx, etc.) which will then proxy the requests to your Rails app. Since the assets are precompiled, Apache/Nginx/etc. can directly serve them without needing to talk to your Rails processes.

Precompile your assets on local server using the below cmd from app

$>rake assets:precompile RAILS_ENV=production

Then edit your config/environments/roductions.rb and set the below flag to true, so that rails server sends assets from server

config.serve_static_assets = false

then start your local server as production

$>rails server -e production

Post your usage u can remove the precompiled assets from the local env using

     $>rake assets:clean


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s