CodeName
CodeName

Reputation: 395

Ruby on rails how to get Delayed::job Handler content as String

i have model contact_message. Every time i send one i create a timeout delayed job like that:

Delayed::Job.enqueue ContactMessageTimout.new(self.permalink) ..

I would really like the possibility to get back the permalink in a delayed::job so i could know which contact_message has a delayed_job
BUT the information is encoded in the key 'handler' like this:

--- !ruby/struct:ContactMessageTimeout
message_permalink: !binary |-
  ZmY2YzAxOTM0MDRjNmIzMjQzMzg=

And the real permalink is : ff6c0193404c6b324338

So how can i deserialize the content of the delayed::job handler?

Thanks a lot

Upvotes: 0

Views: 659

Answers (1)

Daiku
Daiku

Reputation: 1227

That would be Base64 encoding, which converts binary into a format that is safe for XML. You can verify this in the rails console:

 my_proj » Base64.decode64("ZmY2YzAxOTM0MDRjNmIzMjQzMzg=")
 => "ff6c0193404c6b324338"

And of course, you can simply make the same call in your code to get your binary value back.

Upvotes: 1

Related Questions