Stylesheets in E-Mails when using extra sidekiq server

151 views Asked by At

we have the following server setup:

  • Application Server
  • Background Job Server (ActiveJob with Sidekiq)
  • Database Server

The normal workflow would be:

  1. User visits site and fills out register form
  2. After submit a welcome email gets set to deliver_later
  3. Sidekiq does the delivering.

Now we use premailer-rails for styling our emails. The css file is located under app/assets/stylesheets/emails/base.scss. We reference it in the mail.html.haml-Layout with stylesheet_link_tag 'emails/base'. This works great in development and when previewing the mails.

But if we deploy everything and test it out on production we're getting the error: ActionView::Template::Error: The asset "emails/base.css" is not present in the asset pipeline

It works very well when we're telling capistrano to precompile the assets also on the worker server. But this seems to be a little overhead.

Is this the only solution to fix the problem?
Does anyone have a similar setup and problem?

Regards,
spa

1

There are 1 answers

1
Himanshu Tiwari On

By default, Rails assumes that you have your files pre-compiled in the production environment if you want to use live compiling (compile your assets during runtime) in production you must set the config.assets.compile to true.

config/environments/production.rb ...

config.assets.compile = true