Use `update_all` to prevent `after_commit` from executing again.

This commit is contained in:
Robin Ward 2014-04-10 13:19:38 -04:00
parent 605e60b016
commit 99e2bab62d
1 changed files with 2 additions and 2 deletions

View File

@ -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