From 99e2bab62d27f18db80adb88f2829a27534c7b2e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 10 Apr 2014 13:19:38 -0400 Subject: [PATCH] Use `update_all` to prevent `after_commit` from executing again. --- app/jobs/regular/crawl_topic_link.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/jobs/regular/crawl_topic_link.rb b/app/jobs/regular/crawl_topic_link.rb index c0fce0c4cc1..5d7186550d9 100644 --- a/app/jobs/regular/crawl_topic_link.rb +++ b/app/jobs/regular/crawl_topic_link.rb @@ -98,14 +98,14 @@ module Jobs title.gsub!(/ +/, ' ') title.strip! if title.present? - crawled = topic_link.update_attributes(title: title[0..255], crawled_at: Time.now) + crawled = (TopicLink.where(id: topic_link.id).update_all(['title = ?, crawled_at = CURRENT_TIMESTAMP', title[0..255]]) == 1) end end end rescue Exception # If there was a connection error, do nothing ensure - topic_link.update_column(:crawled_at, Time.now) if !crawled && topic_link.present? + TopicLink.where(id: topic_link.id).update_all('crawled_at = CURRENT_TIMESTAMP') if !crawled && topic_link.present? end end