Rails Worker can't find assets

I use Sidekiq on a worker for my Rails app which works totally fine.

I now want Sidekiq to send an email with an image from my assets pipeline. Unfortunately it always said, that it can’t find that image in the assets:

ActionView: : Template: :Error:
The asset "my-image.png" is not present in the asset pipeline.

I’ve added the precompile and clean command to my build command for that worker:

bundle install && bundle exec rake assets:precompile && bundle exec rake assets:clean

Any suggestions why it doesn’t find that image?

I had a similar issue that was solved by adding the precompile & clean as you’ve mentioned, but I also had to use an entire script to set a few other settings. For my build command I have ./bin/render-build-worker.sh and then in that file I have:

# exit on error
set -o errexit

bundle config set without development test
bundle config set force_ruby_platform true # https://stackoverflow.com/a/66311533
bundle install
bundle exec rake assets:precompile
bundle exec rake assets:clean

I don’t think the extra config settings should help unless you’re running into an error, but I guess you never know.

Thanks for your suggestion.

In the meantime I’ve found out that you might have to explicitly set the asset_host for the action mailer: Action Mailer Basics — Ruby on Rails Guides

I’ll first try that. If that doesn’t help, I’ll dig deeper into your suggestion. :pray:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.