]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/old_way.rb
way stuff, now creates correctly
[rails.git] / app / models / old_way.rb
index 3f978d3d407ad88ca44bcaf7d9586c61ddbd8db9..db0108ea8f47232c0754899cb216a653579e4700 100644 (file)
@@ -8,7 +8,50 @@ class OldWay < ActiveRecord::Base
     old_way.user_id = way.user_id
     old_way.timestamp = way.timestamp
     old_way.id = way.id
+    old_way.segs = way.segs
+    old_way.tags = way.tags
     return old_way
   end
 
+  def save_with_dependencies
+    save()
+    self.reload()
+
+    self.tags.each do |k,v|
+      tag = OldWayTag.new
+      tag.k = k
+      tag.v = v
+      tag.id = self.id
+      tag.version = self.version
+      tag.save
+    end
+
+    i = 0
+    self.segs.each do |n|
+      seg = OldWaySegment.new
+      seg.id = self.id
+      seg.segment_id = n
+      seg.version = self.version
+      seg.save
+    end
+  end
+
+  def segs
+    @segs = Array.new unless @segs
+    @segs
+  end
+
+  def tags
+    @tags = Hash.new unless @tags
+    @tags
+  end
+
+  def segs=(s)
+    @segs = s
+  end
+
+  def tags=(t)
+    @tags = t
+  end
+
 end