Broken Images in Emails Sent via Sidekiq?

October 17, 2014

All of my email is sent via Sidekiq.

I recently setup a second dedicated sidekiq job processing server. I added it to my sidekiq Capistrano role and deployed. All was well, except some of the email being delivered had broken images. Oops. Inspecting the HTML email source revealed that the assets were not using the digest version. Strange.

The reason is because while my Rails application was installed, assets were not being precompiled.
By default Capistrano only precompiles assets in the web role.

If the server doesn’t have precompiled assets, it will refert to the plain versions when building paths. In our case, these do not exist.

The existing server didn’t exhibit this issue as it belonged to both roles.

The solution turns out to be simple. Put this into config/deploy.rb and redeploy.

set :assets_roles, [:web, :sidekiq]