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 ActiveJob::Arguments to override the serialize_argument method and accept those methods. I know 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 the relation ( .pluck(:id) ) and then finding each record in the job worker again, but then what would be the point of having ActiveJob serialization?
Cheers!