Asset pipeline: http://guides.rubyonrails.org/asset_pipeline.html#in-production
There are three caveats:
- You must not run the Capistrano deployment task that precompiles assets.
- You must ensure any necessary compressors or minifiers are available on your development system.
- You must change the following application configuration setting:
Capistrano:
http://capistranorb.com/documentation/advanced-features/overriding-capistrano-tasks/#
deploy.rb:
# clear the previous precompile task
Rake::Task["deploy:assets:precompile"].clear_actions
development.rb
# this prefix prevents serving compiled assets in development
config.assets.prefix = '/assets_dev'
.gitignore
public/assets-dev
Nginx:
location ~ ^/assets/ {
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
Source: https://www.reinteractive.net/posts/116-12-tips-for-the-rails-asset-pipeline
To precompile locally, you need to do the following:
- Setup a dummy production database on your local machine
- Create a production entry in database.yml
- Add in any other dummy settings to load a production environment
- Run RAILS_ENV=production rake assets:clean assets:precompile
- Wait
- Wait some more
- Commit the results in the public/assets folder
- Deploy this