Running local server as production server

http://stackoverflow.com/questions/10098743/rails-3-1-3-trying-to-run-locally-in-production-asset-pipeline-not-working

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


Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s