-
-
Save albus522/ba5bb04205a9dc316304f8f228adda2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TempToRuby < Delayed::PsychExt::ToRuby | |
def visit_Psych_Nodes_Mapping(object) | |
if %r{^!ruby/object:ActiveRecord::AttributeSet}.match(object.tag.to_s) | |
{} | |
elsif %r{^!ruby/object:(.+)$}.match(object.tag.to_s) | |
klass = resolve_class(Regexp.last_match[1]) | |
if klass < ActiveRecord::Base | |
payload = Hash[*object.children.map { |c| accept c }] | |
id = payload['raw_attributes'][klass.primary_key] | |
klass.unscoped.find(id) | |
else | |
super | |
end | |
else | |
super | |
end | |
end | |
end | |
job = Delayed::Job.find(bad_job_id) | |
job.payload_object = TempToRuby.create.accept(Psych.parse(job.handler)) | |
job.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment