]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/node.rb
Set the reported_user in a callback
[rails.git] / app / models / node.rb
index 2a64259c10c0832d16c4ec8e2008aa7e34985947..f4367e45954edf51964b903ce54b733c89f8de0b 100644 (file)
@@ -232,14 +232,18 @@ class Node < ActiveRecord::Base
 
   def save_with_history!
     t = Time.now.getutc
+
+    self.version += 1
+    self.timestamp = t
+
     Node.transaction do
-      self.version += 1
-      self.timestamp = t
-      save!
+      # clone the object before saving it so that the original is
+      # still marked as dirty if we retry the transaction
+      clone.save!
 
       # Create a NodeTag
       tags = self.tags
-      NodeTag.delete_all(:node_id => id)
+      NodeTag.where(:node_id => id).delete_all
       tags.each do |k, v|
         tag = NodeTag.new
         tag.node_id = id