TurboSteam and variants

I do agree that keeping it to one view is best in this case, but wanted to show you how to go about passing data from the “controller space” into background jobs:

This is the example, which implements it:

  1. Create a device_variant in a Current model, i.e.
class Current < ActiveSupport::CurrentAttributes
  attribute :device_variant
end
  1. Set device_variant on the controller level in a before action
Current.device_variant = request.variant
  1. Add the current parameter to all jobs - see the #serialize from the example
    def serialize
      super.merge('device_variant' => Current.device_variant)
    end
  1. Finally, access device_variant as in the example code, or I think it should also be available directly in the job with self.arguments, but I haven’t tried it.