Make things work with multipart keys.
authorTom Hughes <tom@compton.nu>
Wed, 23 Jan 2008 09:53:35 +0000 (09:53 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 23 Jan 2008 09:53:35 +0000 (09:53 +0000)
app/controllers/api_controller.rb
app/models/old_way.rb
app/models/old_way_node.rb
app/models/way.rb

index a17e630c2c9657215132f65d068216c146a5e136..28d0f413bbfa04df7a9c08af8ff26d843eca2a51 100644 (file)
@@ -161,7 +161,7 @@ class ApiController < ApplicationController
     ways = Array.new
     if node_ids.length > 0
       way_nodes = WayNode.find_all_by_node_id(node_ids)
-      way_ids = way_nodes.collect {|way_node| way_node.id }
+      way_ids = way_nodes.collect {|way_node| way_node.id[0] }
       ways = Way.find(way_ids)
 
       list_of_way_nodes = ways.collect { |way|
index aa9c81d0ab9b5864c9e6f809a24c29e08fdf11d3..a2b165e42716f5cfa7f095aa76654616274f95b5 100644 (file)
@@ -38,15 +38,13 @@ class OldWay < ActiveRecord::Base
       tag.save!
     end
 
-    i = 1
+    sequence = 1
     self.nds.each do |n|
       nd = OldWayNode.new
-      nd.id = self.id
+      nd.id = [self.id, self.version, sequence]
       nd.node_id = n
-      nd.sequence_id = i
-      nd.version = self.version
       nd.save!
-      i += 1
+      sequence += 1
     end
   end
 
index 5260ee698f5b8df2e356c12284c002ea9f1bc85b..85a6f3c1c6da03105582de4243bbaf90c893f9d6 100644 (file)
@@ -1,6 +1,5 @@
 class OldWayNode < ActiveRecord::Base
-  belongs_to :user
-
   set_table_name 'way_nodes'
 
+  set_primary_keys :id, :version, :sequence_id
 end
index ff2e643709b24bf2a2c9a423b208e52701e6a812..1fe628171c9f91eefc47c050e70efb773e6715b7 100644 (file)
@@ -177,14 +177,13 @@ class Way < ActiveRecord::Base
 
       WayNode.delete_all(['id = ?', self.id])
 
-      i = 1
+      sequence = 1
       nds.each do |n|
         nd = WayNode.new
-        nd.id = self.id
+        nd.id = [self.id, sequence]
         nd.node_id = n
-        nd.sequence_id = i
         nd.save!
-        i += 1
+        sequence += 1
       end
     end