From: Steve Coast Date: Mon, 27 Nov 2006 10:35:10 +0000 (+0000) Subject: rails way bits X-Git-Tag: live~8634 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/db1e02adb5f8eea1fc47bfe4e7b116359d92eaa2 rails way bits --- diff --git a/app/controllers/old_way_controller.rb b/app/controllers/old_way_controller.rb index 7fbed26ea..9c3a257c4 100644 --- a/app/controllers/old_way_controller.rb +++ b/app/controllers/old_way_controller.rb @@ -1,2 +1,4 @@ class OldWayController < ApplicationController + + end diff --git a/app/controllers/old_way_segment_controller.rb b/app/controllers/old_way_segment_controller.rb new file mode 100644 index 000000000..4e9404c9b --- /dev/null +++ b/app/controllers/old_way_segment_controller.rb @@ -0,0 +1,2 @@ +class OldWaySegmentController < ApplicationController +end diff --git a/app/controllers/old_way_tag_controller.rb b/app/controllers/old_way_tag_controller.rb new file mode 100644 index 000000000..02c1e2e65 --- /dev/null +++ b/app/controllers/old_way_tag_controller.rb @@ -0,0 +1,2 @@ +class OldWayTagController < ApplicationController +end diff --git a/app/controllers/way_controller.rb b/app/controllers/way_controller.rb index 49a3b3bfe..2fd4390e4 100644 --- a/app/controllers/way_controller.rb +++ b/app/controllers/way_controller.rb @@ -10,8 +10,6 @@ class WayController < ApplicationController if way way.user_id = @user.id if way.save_with_history - - render :text => way.id else render :nothing => true, :status => 500 @@ -52,7 +50,5 @@ class WayController < ApplicationController way.save_with_history end - end - end diff --git a/app/helpers/old_way_segment_helper.rb b/app/helpers/old_way_segment_helper.rb new file mode 100644 index 000000000..8299bdd27 --- /dev/null +++ b/app/helpers/old_way_segment_helper.rb @@ -0,0 +1,2 @@ +module OldWaySegmentHelper +end diff --git a/app/helpers/old_way_tag_helper.rb b/app/helpers/old_way_tag_helper.rb new file mode 100644 index 000000000..c23661b8a --- /dev/null +++ b/app/helpers/old_way_tag_helper.rb @@ -0,0 +1,2 @@ +module OldWayTagHelper +end diff --git a/app/models/old_way.rb b/app/models/old_way.rb index 3f978d3d4..1aac4ebff 100644 --- a/app/models/old_way.rb +++ b/app/models/old_way.rb @@ -8,7 +8,58 @@ 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 + t = Time.now + self.timestamp = t + self.save + + WayTag.delete_all(['id = ?', self.id]) + + self.tags.each do |k,v| + tag = WayTag.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.id = self.id + seg.segment_id = n + seg.sequence_id = i + seg.save + i += 1 + end + + old_way = OldWay.from_way(self) + old_way.save + 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