]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/old_way.rb
Improve handling of user to user messages.
[rails.git] / app / models / old_way.rb
index 06260425389c2c8db9ea84cc23c18000f609e962..e4df258167ca3b7f4fff49b42f014cef4d63b6c5 100644 (file)
@@ -5,6 +5,7 @@ class OldWay < ActiveRecord::Base
 
   def self.from_way(way)
     old_way = OldWay.new
+    old_way.visible = way.visible
     old_way.user_id = way.user_id
     old_way.timestamp = way.timestamp
     old_way.id = way.id
@@ -37,7 +38,7 @@ class OldWay < ActiveRecord::Base
       tag.save!
     end
 
-    i = 0
+    i = 1
     self.segs.each do |n|
       seg = OldWaySegment.new
       seg.id = self.id
@@ -48,11 +49,22 @@ class OldWay < ActiveRecord::Base
   end
 
   def segs
-    @segs = Array.new unless @segs
+    unless @segs
+        @segs = Array.new
+        OldWaySegment.find(:all, :conditions => ["id = ? AND version = ?", self.id, self.version], :order => "sequence_id").each do |seg|
+            @segs += [seg.segment_id]
+        end
+    end
     @segs
   end
 
   def tags
+    unless @tags
+        @tags = Hash.new
+        OldWayTag.find(:all, :conditions => ["id = ? AND version = ?", self.id, self.version]).each do |tag|
+            @tags[tag.k] = tag.v
+        end
+    end
     @tags = Hash.new unless @tags
     @tags
   end