Created
January 18, 2014 19:06
-
-
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.
This file contains hidden or 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
# 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