Active Job/GlobalID custom types

Hi all,

We just updated our app to rails 4.2, and implemented ActiveJob for our
background jobs (were using Resque). I’ve read the docs and the code,
and I
couldn’t find a “best practice” to accept custom types as job arguments.

I’ve managed to make a class serializable by mixing in
GlobalID::Identification and implementing .find and #id methods. But
then I
started to have more errors, particularly with BigDecimal and
ActiveRecord::AssociationRelation parameters.

The quick fix was to create an initializer and reopen
to override the serialize_argument method and accept those methods. I
it’s not the best option as for example relation arguments would get
converted to an array and it could be a lot of records.

So I wanted to know your opinion and how would you do it.

Other possible solution would be just to get the id of each record in
relation ( .pluck(:id) ) and then finding each record in the job worker
again, but then what would be the point of having ActiveJob


Ok, I kind of found the solution using callbacks, but still
the problem for executing all the relation that may be too big.

Any idea?