Tintin81
Tintin81

Reputation: 10215

How to pass view_context to ActiveJob background worker?

I am trying to pass the view_context object to a background worker:

invoices = current_user.invoices
ArchiveInvoicesJob.perform_later(invoices.pluck(:id), view_context)

I understand that I cannot pass ActiveRecord:Relations to ActiveJob. That's why I'm passing the IDs instead.

But when I try to pass the view_context I get an ActiveJob::SerializationError.

The problem is that I need the view_context inside my Prawn PDF class to generate a bunch of PDFs.

How do I get it in there?

Upvotes: 1

Views: 324

Answers (0)

Related Questions