Skip to content

Loading…

Avoid jobs failed by ActiveRecord::RecordNotFound #29

Merged
merged 1 commit into from

2 participants

@rodacato

Does this make sense for you, to avoid activerecord errors when delete the resource you are going to process before process it?

@lardawge lardawge merged commit 5c76e22 into lardawge:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 24, 2012
  1. @rodacato
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/backgrounder/workers/process_asset.rb
View
15 lib/backgrounder/workers/process_asset.rb
@@ -11,14 +11,17 @@ def self.perform(*args)
def perform
resource = klass.is_a?(String) ? klass.constantize : klass
- record = resource.find id
- record.send(:"process_#{column}_upload=", true)
- if record.send(:"#{column}").recreate_versions! && record.respond_to?(:"#{column}_processing")
- record.update_attribute :"#{column}_processing", nil
+ record = resource.find_by_id id
+
+ if record
+ record.send(:"process_#{column}_upload=", true)
+ if record.send(:"#{column}").recreate_versions! && record.respond_to?(:"#{column}_processing")
+ record.update_attribute :"#{column}_processing", nil
+ end
end
end
-
+
end # ProcessAsset
-
+
end # Workers
end # Backgrounder
Something went wrong with that request. Please try again.