Saturday, 31 August 2013

Pass a Nokogiri::XML::Element into Delayed Job

Pass a Nokogiri::XML::Element into Delayed Job

I create a variable, called node:
doc.xpath('//Product').each do |node|
and pass it into a delayed job like this:
delay.create_new_book_record(client_id, user_id, node)
and although the variable 'node' I'm passing in looks something like this
just before I pass it into the delayed method:
//node.inspect #=>
<Product>
<RecordReference>9780857380272</RecordReference>
<NotificationType>02</NotificationType>
#...etc
it is passed in like this to delayed job which looks like an empty hash to
me:
INSERT INTO "delayed_jobs"
....
:create_new_book_record\nargs:\n- 1\n- 2\n-
!ruby/object:Nokogiri::XML::Element {}\n"]
And the error that gets thrown when I try to parse node in the delayed_job
task is
wrong argument type Nokogiri::XML::Element (expected Data)
So: how do I pass a Nokogiri::XML::Element into a delayed job task so that
it can be processed within the task?

No comments:

Post a Comment