Posted 30 days ago. Visible to the public.

How to skip Sprockets asset compile during Capistrano deployment

For applications coming with lots of stylesheets and scripts, asset compilation might take quite long. This can be annoying when deploying a release that does not actually change assets.

When your app uses Sprockets, you can simply skip asset compilation and re-use the previous release's assets. [1]
That is especially easy via Capistrano. Capistrano will automatically symlink your release's public/assets to a shared directory, so all you need to do is skip the deploy:assets:precompile task.

Put the following code where you'd put other custom Capistrano tasks (default is lib/capistrano/tasks/*.rake)

if ENV['SKIP_ASSETS'] Rake::Task['deploy:assets:precompile'].clear_actions end

You can then set the above environment variable when deploying:

SKIP_ASSETS=1 cap staging deploy


[1] Sprockets will pick any public/assets/.sprocket-manifest-*.json.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Author of this card:

Arne Hartherz
Last edit:
30 days ago
by Arne Hartherz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev