Skip to content

Commit

Permalink
Update each associated record's updated_at individually, this avoids …
Browse files Browse the repository at this point in the history
…deadlocks when touches with shared associations are triggered close together.
  • Loading branch information
Kevin Pheasey committed Dec 30, 2015
1 parent dab603d commit 7271ed4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/active_touch/touch_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ def perform(record, association, after_touch)
associated.send(after_touch) unless after_touch.blank?

elsif !associated.nil?
associated.update_all(updated_at: record.updated_at)
associated.each { |associate| associate.send(after_touch) } unless after_touch.blank?
associated.each do |associate|
associate.update_columns(updated_at: record.updated_at)
associate.send(after_touch) unless after_touch.blank?
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/active_touch/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ActiveTouch
VERSION = '1.4.0'
VERSION = '1.4.1'
end

0 comments on commit 7271ed4

Please sign in to comment.