In our recent project ,

we came across one scenario, where we had to pass an unsaved record as argument in background job.

As delayed_job doesn't allow unsaved AR objects as arguments

ref: delayed_job issue when deserialising arguments

we used serializing/deserialising approach for passing params.

class PassingData
  def serialize(data)
    Base64.encode64(Marshal.dump(data))
  end

  def deserialize(serialized_data)
    serialized_data = Base64.decode64(serialized_data)
    Marshal.load serialized_data
  end
end

user_details = PassingData.serialize @user 

where @user = user_data

Mailer.delay.order_process("order confirm", user_details) #send mail in background

#mailer method
def order_process(subject, user_details)
  user = PassingData.deserialize(user_details)
  .....
end