]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/way.rb
Rename xml processing methods with an update_ prefix
[rails.git] / app / models / way.rb
index 98c4902f9e693cd2396aaf84761df00c0c3a8d83..9586094ff10951020aed5f27b2394bf201933303 100644 (file)
@@ -255,6 +255,9 @@ class Way < ActiveRecord::Base
   def save_with_history!
     t = Time.now.getutc
 
+    self.version += 1
+    self.timestamp = t
+
     # update the bounding box, note that this has to be done both before
     # and after the save, so that nodes from both versions are included in the
     # bbox. we use a copy of the changeset so that it isn't reloaded
@@ -263,12 +266,12 @@ class Way < ActiveRecord::Base
     cs.update_bbox!(bbox) unless nodes.empty?
 
     Way.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!
 
       tags = self.tags
-      WayTag.delete_all(:way_id => id)
+      WayTag.where(:way_id => id).delete_all
       tags.each do |k, v|
         tag = WayTag.new
         tag.way_id = id
@@ -278,7 +281,7 @@ class Way < ActiveRecord::Base
       end
 
       nds = self.nds
-      WayNode.delete_all(:way_id => id)
+      WayNode.where(:way_id => id).delete_all
       sequence = 1
       nds.each do |n|
         nd = WayNode.new