Skip to content

Instantly share code, notes, and snippets.

@spilliton
Created January 18, 2014 19:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spilliton/8494752 to your computer and use it in GitHub Desktop.
Save spilliton/8494752 to your computer and use it in GitHub Desktop.
Monkey patch for delayed_job to to ignore Delayed::DeserializationError when a job is run against a deleted active record model.
# config/initializers/delayed_job_config.rb
module Delayed
module Backend
module Base
def invoke_job_with_deserialize_catch
begin
invoke_job_without_deserialize_catch
rescue Delayed::DeserializationError
Rails.logger.error "Record was deleted when job ran!"
end
end
alias_method_chain :invoke_job, :deserialize_catch
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment