belongs_to :user
- has_many :way_segments, :foreign_key => 'id'
+ has_many :way_segments, :foreign_key => 'id', :order => 'sequence_id'
has_many :way_tags, :foreign_key => 'id'
- has_many :old_ways, :foreign_key => :id
+ has_many :old_ways, :foreign_key => 'id', :order => 'version'
set_table_name 'current_ways'
t = Time.now
self.timestamp = t
self.save!
-
+
+ tags = self.tags
+
WayTag.delete_all(['id = ?', self.id])
- self.tags.each do |k,v|
+ tags.each do |k,v|
tag = WayTag.new
tag.k = k
tag.v = v
tag.save!
end
+ segs = self.segs
+
WaySegment.delete_all(['id = ?', self.id])
-
+
i = 0
- self.segs.each do |n|
+ segs.each do |n|
seg = WaySegment.new
seg.id = self.id
seg.segment_id = n