more way bits
This commit is contained in:
parent
db1e02adb5
commit
8de8ef4f6b
6 changed files with 30 additions and 8 deletions
|
@ -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
|
||||
|
|
2
app/models/old_way_segment.rb
Normal file
2
app/models/old_way_segment.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class OldWaySegment < ActiveRecord::Base
|
||||
end
|
2
app/models/old_way_tag.rb
Normal file
2
app/models/old_way_tag.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class OldWayTag < ActiveRecord::Base
|
||||
end
|
|
@ -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
|
||||
|
|
11
db/migrate/013_create_old_way_tags.rb
Normal file
11
db/migrate/013_create_old_way_tags.rb
Normal file
|
@ -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
|
11
db/migrate/014_create_old_way_segments.rb
Normal file
11
db/migrate/014_create_old_way_segments.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue