more way bits
authorSteve Coast <steve@asklater.com>
Mon, 27 Nov 2006 10:38:32 +0000 (10:38 +0000)
committerSteve Coast <steve@asklater.com>
Mon, 27 Nov 2006 10:38:32 +0000 (10:38 +0000)
app/models/old_way.rb
app/models/old_way_segment.rb [new file with mode: 0644]
app/models/old_way_tag.rb [new file with mode: 0644]
app/models/way.rb
db/migrate/013_create_old_way_tags.rb [new file with mode: 0644]
db/migrate/014_create_old_way_segments.rb [new file with mode: 0644]

index 1aac4ebff8e7736117aa0b8d5e9c0911a1a5b13d..820437fcefbe0211d66b70992437ad2e6a901626 100644 (file)
@@ -13,26 +13,22 @@ class OldWay < ActiveRecord::Base
     return old_way
   end
 
-  def save
+  def save_with_dependencies
     t = Time.now
     self.timestamp = t
     self.save
     
-    WayTag.delete_all(['id = ?', self.id])
-
     self.tags.each do |k,v|
-      tag = WayTag.new
+      tag = OldWayTag.new
       tag.k = k
       tag.v = v
       tag.id = self.id
       tag.save
     end
 
-    WaySegment.delete_all(['id = ?', self.id])
-    
     i = 0
     self.segs.each do |n|
-      seg = WaySegment.new
+      seg = OldWaySegment.new
       seg.id = self.id
       seg.segment_id = n
       seg.sequence_id = i
diff --git a/app/models/old_way_segment.rb b/app/models/old_way_segment.rb
new file mode 100644 (file)
index 0000000..4f96f74
--- /dev/null
@@ -0,0 +1,2 @@
+class OldWaySegment < ActiveRecord::Base
+end
diff --git a/app/models/old_way_tag.rb b/app/models/old_way_tag.rb
new file mode 100644 (file)
index 0000000..7fe6196
--- /dev/null
@@ -0,0 +1,2 @@
+class OldWayTag < ActiveRecord::Base
+end
index 9ae45d40fe07dc5ab123ce645b2d3e30223f4829..55b953ce9439fb40b61c6ea0847b1ca20669733a 100644 (file)
@@ -121,7 +121,7 @@ class Way < ActiveRecord::Base
     end
 
     old_way = OldWay.from_way(self)
-    old_way.save
+    old_way.save_with_dependencies
   end
 
 end
diff --git a/db/migrate/013_create_old_way_tags.rb b/db/migrate/013_create_old_way_tags.rb
new file mode 100644 (file)
index 0000000..97f0d76
--- /dev/null
@@ -0,0 +1,11 @@
+class CreateOldWayTags < ActiveRecord::Migration
+  def self.up
+    create_table :old_way_tags do |t|
+      # t.column :name, :string
+    end
+  end
+
+  def self.down
+    drop_table :old_way_tags
+  end
+end
diff --git a/db/migrate/014_create_old_way_segments.rb b/db/migrate/014_create_old_way_segments.rb
new file mode 100644 (file)
index 0000000..a7bffb8
--- /dev/null
@@ -0,0 +1,11 @@
+class CreateOldWaySegments < ActiveRecord::Migration
+  def self.up
+    create_table :old_way_segments do |t|
+      # t.column :name, :string
+    end
+  end
+
+  def self.down
+    drop_table :old_way_segments
+  end
+end