Search code examples
rubyruby-on-rails-3delayed-job

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


Solution

  • 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.