Make sure we get the list of tags and segments to save before we do the
authorTom Hughes <tom@compton.nu>
Sun, 24 Jun 2007 11:12:52 +0000 (11:12 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 24 Jun 2007 11:12:52 +0000 (11:12 +0000)
corresponding delete, as otherwise we might not have read them from the
database yet.

app/models/way.rb

index 9658a99291a2b6655013b5c8a4df533f47bf623f..fe16e98c3257f86cbaa795cd8d3765ed4fd6f3ae 100644 (file)
@@ -148,10 +148,12 @@ class Way < ActiveRecord::Base
         t = Time.now
         self.timestamp = t
         self.save!
-    
+
+        tags = self.tags
+
         WayTag.delete_all(['id = ?', self.id])
 
-        self.tags.each do |k,v|
+        tags.each do |k,v|
           tag = WayTag.new
           tag.k = k
           tag.v = v
@@ -159,10 +161,12 @@ class Way < ActiveRecord::Base
           tag.save!
         end
 
+        segs = self.segs
+
         WaySegment.delete_all(['id = ?', self.id])
-    
+
         i = 0
-        self.segs.each do |n|
+        segs.each do |n|
           seg = WaySegment.new
           seg.id = self.id
           seg.segment_id = n